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

output is:

{1..30}  

What is wrong in my code?

ceving
  • 21,900
  • 13
  • 104
  • 178
Ilya
  • 29,135
  • 19
  • 110
  • 158
  • 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
  • 155,172
  • 47
  • 273
  • 272
3

Alternatively you can switch to a while construction:

i=1
while (( i <= 30 ))
do
   echo $i
   (( i+=1 ))
done
Juan Diego Godoy Robles
  • 14,447
  • 2
  • 38
  • 52
0
 for {set x 0} {$x<10} {incr x} {
             puts "x is $x"
           }