I was going through the shell script book, but in the array section, I got stuck. when I declare the array and run the script like:
sh hello.sh
it shows me the error, even in ZSH, is below:
one.sh: 2: Syntax error: "(" unexpected
when I run like this ./hello.sh
, it's working like a charm.
This is the Script
#!/bin/bash
myarr=(on two three four five)
echo "${myarr[1]}"
exit 0
Note: why the sh
isn't working, please. I'm a newbie in the shell!
one
wrong. – ctrl-alt-delor Dec 22 '19 at 16:57