Appending a New Value to the End of an Array in Bash
Short Version
Command | Case |
---|---|
array[${# array[*]}]="$variable" |
Indexed at zero |
array[${# array[*]}+1]="$variable" |
Indexed at one |
Explanation
I haven’t found an easier way, but several harder ways to do this. The harder ways often include some sort of loop or creating a new array with the same name and appending the new value to the old values.