小编mak*_*gun的帖子

Bash 的无限“for”循环

我有一个像这样的脚本

#!/bin/bash
for i in {1..xx};do break="$i"
If....; then Some command
else break;fi
done
Run Code Online (Sandbox Code Playgroud)

我需要一些可以通过增加 $i 来重复此脚本 n 次的东西。

我试过这个:

For (( ; ; )); do  i=1 && echo $i && ((i++));done
Run Code Online (Sandbox Code Playgroud)

但这始终显示 1,而不是递增的数字。我也尝试过$((i+=1))

那里xx一定是无穷无尽的。

哪里break="$i"给了我重复脚本多少次。

bash scripting ubuntu

-1
推荐指数
1
解决办法
5368
查看次数

标签 统计

bash ×1

scripting ×1

ubuntu ×1