syntax of for loop in linux shell scripting syntax of for loop in linux shell scripting shell shell

syntax of for loop in linux shell scripting


You probably run it with sh, not bash. Try bash test1.sh, or ./test1.sh if it's executable, but not sh test1.sh.


A standard POSIX shell only accepts the syntax for varname in list

The C-like for-loop syntax for (( expr1; expr2; expr3 )) is a bashism.

You can get similar behavior in the standard POSIX shell using for c in $(seq 1 5)


What does

ls -l /bin/sh

give on your machine ?

Make sh a symbolic link to bash and then you can do sh ./test1.sh