6
#!/bin/ksh
#########################     
for i in {1..30} ;do
  echo $i
done

output is:

{1..30}  

What is wrong in my code?

ceving
  • 19,833
  • 10
  • 94
  • 150
Ilya
  • 28,466
  • 18
  • 106
  • 153
  • Possible duplicate of [for loop range not working ksh](http://stackoverflow.com/questions/3005265/for-loop-range-not-working-ksh) – ceving Nov 25 '16 at 15:32

3 Answers3

6

{1..30} belongs to bash.

Use this:

for((i=1;i<=30;i++)); do
    echo $i
done
kev
  • 146,428
  • 41
  • 264
  • 265
3

Alternatively you can switch to a while construction:

i=1
while (( i <= 30 ))
do
   echo $i
   (( i+=1 ))
done
Juan Diego Godoy Robles
  • 13,642
  • 2
  • 42
  • 51
0
 for {set x 0} {$x<10} {incr x} {
             puts "x is $x"
           }