Here is myscript.sh
#!/bin/bash
for i in {1..$1};
do
echo $1 $i;
done
If I run myscript.sh 3
the output is
3 {1..3}
instead of
3 1
3 2
3 3
Clearly $3
contains the right value, so why doesn't for i in {1..$1}
behave the same as if I had written for i in {1..3}
directly?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…