I want to run this script:
I run it as:
And I get "
Syntax error: "(" unexpected" . I found some similar situations but still can't solve this.
I'm a beginner at shell scripting , but as I understand:
- the shebang I use is correct and chooses the bash shell , so the process substitution syntax should work
- I try the same from the command line and it works. I checked with
echo $0and it gives me "
bash" , so what's the difference from running the command in the command line and from a script that invokes the same shell?
Maybe it's something simple, but I couldn't find an explanation or solution.
You should run your script with
bash, i.e. either
bash ./script.sh or making use of the shebang by
./script.sh after setting it to executable. Only running it with
sh ./script.sh do I get your error, as commented by Cyrus.
See also: role of shebang at unix.SE
export POSIXLY_CORRECT=1 from your
~/.profile (etc.) files.
The issue is that process substitution is an added bash feature that is not part of the posix standards.
errorsh: 3: Syntax error: "(" unexpected