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.



57 Words

2010-08-05 10:16 +0000