My suspicion is that the OP is attempting to execute the script with sh
directly, like this:
If so, then the #!/bin/bash
shebang at the top of the script is being ignored and it's being parsed by /bin/sh
instead. And if /bin/sh
is symlinked to dash
or a similar strictly posix shell, then arrays aren't supported.
If a script has the proper shebang, then just chmod
it to be executable and launch it directly:
./scriptname.sh #assuming pwd contains the script.
This way it will be interpreted by the shell specified in the shebang.
And please use ***[code][/code]
*** tags around your code and data, to preserve the original formatting and to improve readability. Do not
use quote tags, bolding, colors, "start/end" lines, or other creative techniques.