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


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.


Your rating: None Average: 3.5 (4 votes)