Today, the script on the company server to get its own notebook on the run error, set-x tracking discovery is a variable in the self-increase operation error occurred, the error section of the script is probably like this:
#! /bin/sh
param=0
echo $ ((param++))
Error message:
$/test.sh
./test.sh:3:./test.sh:arithmetic expression:expecting Primary: "param++"
There is still an error after replacing (()) in the script with the Let command:
#! /bin/sh
param=0 let
param++
Echo $param
Error message:
$/test.sh
./test.sh:4:./test.sh:let:not found
The script runs correctly on the server, but there is something wrong with your notebook, so it must be the environment on your laptop that is different from the server. My notebook is Ubuntu 16.04, and the server is CentOS, which may be the breakthrough point. Later, after looking, I found that the/bin/sh link in Ubuntu is pointing to the dash shell by default, and the server is pointing at the bash shell. The dash is a small shell, and his function is naturally not bash strong, the above problem is with the dash shell does not support + + operations and let command caused.
Found the reason, the solution is very simple. By directly indicating the use of the bash shell in the script, change the first line of the script to:
#! /bin/bash
# Script Content
# ...
or point/bin/sh directly to bash to fix the problem and enter the command at the terminal:
$: sudo ln-sf/bin/bash/bin/sh