In Bash, arrays are created using parentheses and elements separated by spaces: arrayName=(“element1” “element2″). To access an element, use the index in brackets: ${arrayName[index]}. The first index is 0.
To add an element, assign it to a new index: arrayName[2]=”element3”. For removing an element, unset command is used: unset ‘arrayName[1]’. Length of an array can be found with ${#arrayName[@]}.
For iterating over an array, you can use for loop: for i in “${arrayName[@]}”; do echo $i; done. You can also slice arrays using parameter expansion: ${arrayName[@]:start:length}.