【发布时间】:2018-10-12 16:03:09
【问题描述】:
for i in {0..3}
do
echo $i
done
返回
0
1
2
3
但是
firstNumber=$1
lastNumber=$2
for i in {$firstNumber..$lastNumber}
do
echo $i
done
返回,例如,
{0..3}
如何在 For 循环声明中使用变量?
【问题讨论】:
-
请注意,在 bash 中,
{$min..$max}不起作用。它们必须是静态数字。