shell脚本从文件中读取,并根据模式执行
需要关于shell脚本的建议,以便根据模式读取文件和回显shell脚本从文件中读取,并根据模式执行,shell,unix,loops,scripting,if-statement,Shell,Unix,Loops,Scripting,If Statement,需要关于shell脚本的建议,以便根据模式读取文件和回显 cat revs.txt 1 3 8:13 18:71 89 if x:x then echo "This is revs range" else echo " this is single rev" 读取时 做 中的案例“$rev” (*:*)echo“这是一系列修订$rev”;; (*)回应“这是一个单一版本$rev”;; 以撒 完成
cat revs.txt
1
3
8:13
18:71
89
if x:x then echo "This is revs range"
else
echo " this is single rev"
读取时
做
中的案例“$rev”
(*:*)echo“这是一系列修订$rev”;;
(*)回应“这是一个单一版本$rev”;;
以撒
完成
+1。对于bash,您可以编写一个“if”条件,如下所示:[[$rev==*:*]
while read rev
do
case "$rev" in
(*:*) echo "This is a range of revisions $rev";;
(*) echo "This is a single revision $rev";;
esac
done < revs.txt