Ilya
Ilya

Reputation: 29693

ksh scripting, For loop

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

output is:

{1..30}  

What is wrong in my code?

Upvotes: 6

Views: 40878

Answers (3)

Dbase Cos
Dbase Cos

Reputation: 11

 for {set x 0} {$x<10} {incr x} {
             puts "x is $x"
           }

Upvotes: 0

Juan Diego Godoy Robles
Juan Diego Godoy Robles

Reputation: 14955

Alternatively you can switch to a while construction:

i=1
while (( i <= 30 ))
do
   echo $i
   (( i+=1 ))
done

Upvotes: 3

kev
kev

Reputation: 161654

{1..30} belongs to bash.

Use this:

for((i=1;i<=30;i++)); do
    echo $i
done

Upvotes: 6

Related Questions