For loop

a=5


for i in {1..$a}
do 
something
done

it should take 1...5 , when i run above it throwing error , Please help me

---------- Post updated at 03:12 PM ---------- Previous update was at 02:48 PM ----------

I got it

#!/bin/bash
START=1
END=5
for i in $(eval echo "{$START..$END}")
do
	echo "$i"
done

If you ever find yourself using eval, you've taken a wrong turn somewhere. eval is the right answer to forcing {1..$n} to work but you don't need to use that at all.

for ((X=1; X<=$a; X++))
do
...
done

It is the most efficient method of shooting yourself into everybody elses foot. ;-))

bakunin

also ...

for i in `seq 1 $n`; do echo $i; done

... though you don't need the 1 since you're starting at 1.