I did
a=1234
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.
#!/bin/sh
a=1234;
let "a=a+1";
echo "$a";
Thanks,
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The problem is likely that
/bin/shis not the same as, or does not behave the same as, your normal shell. For example, whenbashis 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:
or
You don’t need the semi-colons at the ends of the lines.