LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   for loop not working (http://www.linuxquestions.org/questions/linux-software-2/for-loop-not-working-946041/)

dth4h 05-20-2012 03:24 PM

for loop not working
 
This code isn't working:
the num variable will change but for this example it equals 10
Code:

for d in {1..$num};do
  echo $d
done

It echos
Code:

{1..10}
instead of what I want it to echo witch is
Code:

1
2
3
4
5
6
7
8
9
10


colucix 05-20-2012 03:28 PM

Same problem as in a recent thread. Please, see reply here.

Ser Olmy 05-20-2012 03:29 PM

Code:

for (( d=1 ; d<=$num ; d++ )); do
  echo $d
done


dth4h 05-20-2012 03:37 PM

Quote:

Originally Posted by Ser Olmy (Post 4683411)
Code:

for (( d=1 ; d<=$num ; d++ )); do
  echo $d
done


You are awesome! Thanks


All times are GMT -5. The time now is 03:26 AM.