I have a script which uses below for loop:
for (( i = 0 ; i <= 5; i++ ))
do
echo "Welcome $i times"
done
But when I run the script, it gives error message:
Syntex Error : Bad for loop variable
Can anyone guide to run it?
Thanks in advance.
I have a script which uses below for loop:
for (( i = 0 ; i <= 5; i++ ))
do
echo "Welcome $i times"
done
But when I run the script, it gives error message:
Syntex Error : Bad for loop variable
Can anyone guide to run it?
Thanks in advance.
for ((a=1; a <= LIMIT ; a++)) # Double parentheses, and "LIMIT" with no "$".
do
echo -n "$a "
done
Nilesh, thanks for quick response.
What should be syntex to get the required output?
Please respond.
Deepak
$ for (( i = 0 ; i <= 5; i++ )); do echo "Welcome $i times"; done
$ for i in $(seq 0 5); do echo "Welcome $i times"; done
$ for i in `seq 0 5`; do echo "Welcome $i times"; done
$ for i in 0 1 2 3 4 5; do echo "Welcome $i times"; done
// Jadu
hay deepak..... run your script with bash instead if running it as sh.
Hi Nilesh/Jaduks,
Thanks for quick suggestions. You guys are making this forum more relevent. Keeping helping like this. Thanks a ton again.
Deepak
What was the mistake in the first script I sent?
Even the first script which u sent was correct.
But, that's still not woking. I am able get reqd output from other ways but I want to get by using paretheses. Any suggestion?
Very sorry.
I got it. I will have to run it by using bash not sh. Anyway, thanks for taking interest in my query.
Deepak
try this,
for ((a=1; a <= LIMIT ; a++))
do
echo -n "\"$a\""
done