在bash中退出循环

时间:2014-06-17 17:23:00

标签: bash shell

我有一个正在处理的脚本,到目前为止一切正常,除非它在输出我需要的信息时不会退出循环

uidAssoc(){
        arg1=$1
        arg2=$2
        for i in $(cat ~/jlog/"$2"); do grep "$1" ~/jlog/"$2" | awk '/\([a-zA-Z0-9.]+/ {print $7}'; done | awk -F'[(/]' '{print $2;exit}'
        echo "Study Instance UID has been found!!"
        break

我知道它没有通过这个循环,因为我echo "Study Instance UID has been found!!"并且它没有产生那个echo语句作为输出。有人可以建议我还能做些什么吗?

1 个答案:

答案 0 :(得分:2)

uidAssoc(){
        arg1=$1
        arg2=$2
        for i in $(cat ~/jlog/"$2")
          do
          # ...
          echo "Study Instance UID has been found!!"
          break
        done
}