(( COUNT++ )) -> "COUNT++: not found" in shell script

shell

Solution

You probably want `#!/bin/bash` rather than `#!/bin/sh` at the top if you want to use bash-specific operations.

Your script does work fine here on my Mac, where `sh` is really just `bash`. If your `sh` is a real one you might not be so lucky.

Problem

``` #!/bin/sh INTERVAL=1 COUNT=0 while [ $COUNT -le 9 ] do (( COUNT++ )) sleep $INTERVAL echo "count is $COUNT" done ``` On execution. ``` $ sh ascript ascript: 9: COUNT++: not found count is 0 ascript: 9: COUNT++: not found count is 0 ascript: 9: COUNT++: not found count is 0 ascript: 9: COUNT++: not found count is 0 ascript: 9: COUNT++: not found count is 0 ascript: 9: COUNT++: not found count is 0 ascript: 9: COUNT++: not found count is 0 ascript: 9: COUNT++: not found ```

Original source