Linux sh shell脚本可以';不要打破循环
sh脚本应该在文件大小=0时工作(如果它没有下载文件,我用stat手动检查,值为“0”),但它没有停止,所以我添加了带break的“if”语句,仍然不工作,我如何才能中断它?请帮忙 注意:可能有其他方法可以自动下载firefox,但我把firefox作为一个轻量级示例放在这里Linux sh shell脚本可以';不要打破循环,linux,loops,terminal,sh,break,Linux,Loops,Terminal,Sh,Break,sh脚本应该在文件大小=0时工作(如果它没有下载文件,我用stat手动检查,值为“0”),但它没有停止,所以我添加了带break的“if”语句,仍然不工作,我如何才能中断它?请帮忙 注意:可能有其他方法可以自动下载firefox,但我把firefox作为一个轻量级示例放在这里 n=0 mm=22 while [ $n -eq 0 ]; do for a in $mm do for b in 0 1 2 3 4 5 6 7 8 9 do for c in ""
n=0
mm=22
while [ $n -eq 0 ]; do
for a in $mm
do
for b in 0 1 2 3 4 5 6 7 8 9
do
for c in "" ".1" ".2"
do
wget -O ff.exe http://download.cdn.mozilla.net/pub/firefox/releases/latest/win32/ru/Firefox%20Setup%20$a.$b$c.exe
n=$(stat -c %s ff.exe)
echo "n = $n"
if [ $n -ne 0 ]; then
echo "n2 = $n"
break
fi
done
done
mm=$(( $mm + 1 ))
done
done
好吧,我想起来了:
n=0
mm=22
while [ $n -eq 0 ]; do
for a in $mm
do
for b in 1 2 0 3 4 5 6 7 8 9
do
if [ $n -ne 0 ]; then
break
fi
for c in "" ".1" ".2"
do
wget -O ff.exe http://download.cdn.mozilla.net/pub/firefox/releases/latest/win32/ru/Firefox%20Setup%20$a.0$c.exe
n=$(stat -c %s ff.exe)
if [ $n -ne 0 ]; then
break
fi
done
done
mm=$(( $mm + 1 ))
done
done
您只是打破了最内部的
for
循环,如果您试图在此时退出脚本,可能应该使用exit
?问题是什么?你是说break
应该导致脚本退出吗?