Bash Array Operations

Posted June 8, 2005 by hpx in Bourne shell scripting

Sometimes we need to remove one element from an array. This Tech-Recipes tutorial contains an example.


We can remove element 2 (third) from an array.

array=(“hello” “i” “like” “bash”)
i=2
array=(${array[@]:0:$i} ${array[@]:$(($i + 1))})

The Conversation

Follow the reactions below and share your own thoughts.