for loop is not working
Hi,
I am not sure why my for loop is not executing. Code:
#!/bin/bash |
I am getting the below output. I never faced this type of problem.
$ sh a.sh 3 3 3 {1..3} $ for i in {1..10};do echo $i;done 1 2 3 4 5 6 7 8 9 10 same works normally.. |
I'm really sure the for loop is working as it was planned to work (by design). Probably it will not do what you have tried to implement....
use set -xv at the beginning of the script (as second line) and you will see what's happening. also add the second loop (posted by bkcreddy17): for i in {1..10};do echo $i;done and you will see: $COUNT was not evaluated "in time", the for cycle got only one value, the string '{1..$COUNT}' and it was evaluated only during the execution of the echo command. |
Code:
]$ sh a.sh |
sorry, I edited my previous post, added explanation
|
not sure why it is picking up as '{1..3}'. any idea?
|
pan,
how can i make, $COUNT evaluated "in time" ? |
Thanks. I changed for loop pattern.
Code:
#!/bin/bash ---------- Post added 25th Oct 2013 at 01:46 PM ---------- This started working. |
so you found the way. (if you really want to say thanks just press YES)
|
Member Response
Moved: This thread is more suitable in <Programming> and has been moved accordingly to help your thread/question get the exposure it deserves.
|
All times are GMT -5. The time now is 01:14 AM. |