I have the following script
list=\(\)
val=123
list+=\(\"$val\"\)
When I copy-paste it to the terminal it works fine, but when I try to run it from inside a .sh
file, I get this error:
file.sh: 9: file.sh: list+=("123"): not found
I found this answer here, but it doesn't seem applicable since I'm not using a space.
btw, I use \
in front of (
because otherwise I get Syntax error: "(" unexpected
, this also happend only when running from a script file.
What causes the error?
I'm working on GNU bash, version 4.3.30(1)-release (x86_64-pc-linux-gnu)