Bash (Scripting) - Get the first element from a List

by
Jeremy Canfield |
Updated: April 21 2023
| Bash (Scripting) articles
Let's say you have an list named fruit that contains the following values.
fruit=(banana apple orange grapes)
Here is how you can return the first item from the list.
echo ${fruit[1]}
Which in this example should return "banana".
banana
Did you find this article helpful?
If so, consider buying me a coffee over at