Arrays
An array keeps a list in numbered slots, counted from 0: songs=("Highway Tea" "Window Down") makes one, ${songs[0]} reads a slot, ${#songs[@]} counts the items, songs+=( ) adds one, "${songs[@]}" hands on every item in one piece, and mapfile -t fills an array from a file's lines.
Updated
![Cheat sheet for the lesson Arrays: An array keeps a list in numbered slots, counted from 0: songs=("Highway Tea" "Window Down") makes one, ${songs[0]} reads a slot, ${#songs[@]} counts the items, songs+=( ) adds one, "${songs[@]}" hands on every item in one piece, and mapfile -t fills an array…](https://fsdtrainingmedia.blob.core.windows.net/public/images/2026/11/b5c153853aaa4e7ebc2fd454e2903565.webp)
- Category
- Bash
- Level
- Journeyman
- Tags
- Array, array-index, linux, mapfile, random, unix, word-splitting