John John - 6 months ago 28
Bash Question

"let" internal shell command doesn't work in a shell script?

I did

let "a=a+1"

on command line and it's fine. But when I do the same in a shell script. It prints out an error that "let: not found".
Here is the script file.

let "a=a+1";
echo "$a";



The problem is likely that /bin/sh is not the same as, or does not behave the same as, your normal shell. For example, when bash is invoked as /bin/sh, it provides a subset of its normal features.

So, you may need to change your shebang line to use a different shell:




You don't need the semi-colons at the ends of the lines.