标签: bash
我有这段代码:
for x in 1 2 3; do ./test.sh $x done
test.sh看起来像这样
echo "$1" if [ "$1" = "2" ] then exit 1 else exit 0 fi
如何才能输出
1 2
而不是
1 2 3
答案 0 :(得分:2)
break:
break
for x in 1 2 3; do ./test.sh $x || break done