I want to run this script:
#!/bin/bash
echo <(true)
I run it as:
sh file.sh
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 $0
and 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.
question from:
https://stackoverflow.com/questions/65848440/syntax-error-near-unexpected-token-bash 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…