Recently when I am using arrays in a script I got the error message as “Shell script arrays Syntax error: “(” unexpected”.
$ sh arrays.sh #In arrays.sh script I defined some arrays trying to extract values form it
The out put I got after running the script is below
Shell script arrays Syntax error: “(” unexpected
I am struggled a bit to resolve this issue, and the solution I got to know is, most probably in your OS the bash version is updated.
So it is unable to resolve the array assignment.
To fix the issue use bash instead of using sh while executing the script, that should not throw any syntax error.
Run arrays.sh as
$ bash arrays.sh