How to use bash array?

bash array shell

Bash shell has syntax for arrays, values should be separated by space and wrapped with round brackets:59a94420fa767fcd0e133132

Defining array in bash:

dirs=('etc' 'www')

It is also possible to define array spanning multiple lines:

dirs=('upload'
'components'
'mail')

Using array in bash (loop):

  for dir in ${dirs[*]}
do
echo "$dir"
done

Above example will display etc and www

Adding element to array

dirs+=("new")

Creating empty array

dirs=()