Bash scripting -- Usage of arrays

Jayesh Jayan jayesh.freebsdlist at
Tue Nov 29 21:11:28 GMT 2005


Today I was trying to script using arrays in FreeBSD 5.4 but it doesn't

Below is a sample script which I used.



array=( zero one two three four);
echo "Elements in array0:  ${array[@]}"


It works fine on RedHat server.

Below is the output.

# sh
Elements in array0:  zero one two three four

Below is the out put from the FreeBSD server using the same code.

-bash-2.05b# sh 3: Syntax error: word unexpected (expecting ")")

Please guide me on how to use arrays on freebsd too.


Jayesh Jayan

"The box said "Requires Windows 95, NT, or better", so I installed Linux."

Visit my homepage @

More information about the freebsd-hackers mailing list