I keep getting bad substitution error on bash scripts with arrays
You need to run the script as bash
and not sh
.
So, run it with
bash test.sh
The other way, you could set the execute
bit on your file by doing
chmod +x test.sh
then just run your script as
./test.sh
because you already have your command shell interpreter (shebang) as your first line #!/bin/bash
.