Do you want BuboFlash to help you learning these things? Or do you want to add or correct something? Click here to log in or create user.



Question

How to delete an array element ?

$ my_array=(foo bar baz)

$ unset my_array[1]

$ echo ${my_array[@]} foo baz

Answer
unset

Question

How to delete an array element ?

$ my_array=(foo bar baz)

$ unset my_array[1]

$ echo ${my_array[@]} foo baz

Answer
?

Question

How to delete an array element ?

$ my_array=(foo bar baz)

$ unset my_array[1]

$ echo ${my_array[@]} foo baz

Answer
unset
If you want to change selection, open document below and click on "Move attachment"

How to use arrays in bash script - LinuxConfig.org
eleting an element from the array To delete an element from the array we need to know it's index or its key in the case of an associative array, and use the unset command. Let's see an example: <span>$ my_array=(foo bar baz) $ unset my_array[1] $ echo ${my_array[@]} foo baz We have created a simple array containing three elements, "foo", "bar" and "baz", then we deleted "bar" from it running unset and referencing the index of "bar" in the array: in this ca

Summary

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

Details

No repetitions


Discussion

Do you want to join discussion? Click here to log in or create user.