The FOR Loop with range values is specially for the BASH shell.
So when you get to other OS ,if the BASH is not set then you will not be getting the expected error.
Code :
echo Shell:: $SHELL
for range in {1..3}
do
echo "Range: $range"
done;
OUTPUT :
So when you get to other OS ,if the BASH is not set then you will not be getting the expected error.
Code :
echo Shell:: $SHELL
for range in {1..3}
do
echo "Range: $range"
done;
OUTPUT :
Linux
|
AIX
|
SUN
|
Shell::/bin/ksh
Range: 1
Range: 2
Range: 3
|
Shell::/bin/ksh
Range: {1..3}
|
Shell::/bin/ksh
Range: {1..3}
|
How to overcome this issue :
Add the "#!/bin/bash" . (find the path of the bash in other os and add it in the script.)
which bash
/usr/bin/bash
Code :
#!/usr/bin/bash
echo Shell::$SHELL
for range in {1..3}
do
echo "Range: $range"
done;
OUTPUT : AIX
Shell::/bin/ksh
Range: 1
Range: 2
Range: 3