Shell Programming/Arrays

From Wikibooks, open books for an open world
< Shell Programming
Jump to navigation Jump to search

To assign a value to an element of an array simply do


To expand the value of an index of an array do

${ArrayName[2]}   # This equals 'ValueForArrayNameIndex2'

The arrays don't need to be full or compact (i.e. there can be null values between some interval of indexes).