Bash: Syntax error near unexpected token `('

From FVue
Jump to: navigation, search

Problem

A shell script is generating this error message:

$ cat incerror.sh
 ((CNT++))
$ bash incerror.sh
incerror.sh: line 1: syntax error near unexpected token `('
incerror.sh: line 1: ` ((CNT++))'

Solution

It appears the space before the command `((CNT++))' isn't an ordinary space 0x20 but a non-breaking space 0xA0. This can be viewed in vim with the command: ga

Replace the non-breaking space with a regular space and execution goes all right:

$ cat incok.sh
 ((CNT++))
$ bash incok.sh 
$

Comments

blog comments powered by Disqus