问题
#!/bin/ksh
#########################
for i in {1..30} ;do
echo $i
done
output is:
{1..30}
What is wrong in my code?
回答1:
{1..30} belongs to bash
.
Use this:
for((i=1;i<=30;i++)); do
echo $i
done
回答2:
Alternatively you can switch to a while construction:
i=1
while (( i <= 30 ))
do
echo $i
(( i+=1 ))
done
回答3:
for {set x 0} {$x<10} {incr x} {
puts "x is $x"
}
来源:https://stackoverflow.com/questions/9977485/ksh-scripting-for-loop