Reputation: 11
#!/bin/bash
ARRAYNAME=( 'time1' 'life' 'time2' )
echo ${ARRAYNAME[1]}
In the above code when i run my script as
$ sh ex1.sh
it gives an error message:
ex1.sh: 2: Syntax error: "(" unexpected
Why is this?
Upvotes: 1
Views: 346
Reputation: 1
Your "shebang" lines uses bash shell ("/bin/bash") but you're probably invoking another shell ("sh") invoking another shell to execute your script. Try this :
$ chmod 700 ex1.sh
This will make your script executable. Then run it :
$ ./ex1.sh
Upvotes: 0