Arrays

Arrays

Creating an empty array (Optional)

declare -a myarray

Assigning values

myarray[2]=alice
myarray[0]=hatter
myarray[1]=dutchess

myarray=([2]=alice [0]=hatter [1]=duchess)

myarray=(hatter duchess alice)

myarray=(hatter [5]duchess alice)
(This assigns hatter to element 0, duchess to element 5 and alice to element 6)

Reassigning to an existing array with a compound array statement replaces the old array with a new one


Send mail to the Webmaster

logo This site best viewed with a browser
Warning: This is a Debian centric site
Many thanks to Debra and Ian Murdock for making Debian possible
First created Apr 22, 2008 ~ Last revised December 21, 2009

Valid XHTML 1.0 Strict Valid CSS!