shell脚本从文件中读取并根据模式执行

时间:2013-06-17 23:06:13

标签: 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"

1 个答案:

答案 0 :(得分:2)

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