I have a for loop and i pass in number of times i want to loop as argument to script.
I have attached a snippet of my script. Problem is this does not work, if I manually replace the $NO_OF_LOOPS with a number in the script it works fine.
NO_OF_LOOPS=$1
for i in {0..$NO_OF_LOOPS}
Any help, i just want to control the no of loops via the argument i pass in.
How about this!
NO_OF_LOOPS=$1
for i in `seq 0 $NO_OF_LOOPS`
do
echo $i
done
NO_OF_LOOPS=$1
for i in `seq 0 $NO_OF_LOOPS`
This will not work.
Error:
seq: invalid floating point argument: _OF_LOOPS
Try `seq --help' for more information.
You need to precede $ infront of NO_OF_LOOPS
It should be like
for i in `seq 1 $NO_OF_LOOPS`
Or in bash
for (( i = 1 ; i <= $1; i++ ))
do
echo "amit $i"
done
I get seq: command not found
kelseyh -
what shell are your using. seq is a bash shell feature.
Have you tried amitranjansahu's solution?
seq will be available under GNU.