Is there a way to do something like PHPs $array[] = 'foo';
in bash vs doing:
array[0]='foo'
array[1]='bar'
Yes there is:
ARRAY=()
ARRAY+=('foo')
ARRAY+=('bar')
In the context where an assignment statement is assigning a value to a shell variable or array index (see Arrays), the ‘+=’ operator can be used to append to or add to the variable's previous value.