# Lists

Lists: Arrays, Associative Arrays: Lists with Names.

Updated: November 10, 2026

1. [Arrays](https://www.ask-codey.com/lessons/bash-arrays) (Journeyman): 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.
2. [Associative Arrays: Lists with Names](https://www.ask-codey.com/lessons/bash-associative-arrays) (Freelancer): An associative array finds each value by a name instead of a number: declare -A total makes one, total\[chill\]=15 stores a value under a name, "${!total\[@\]}" lists the names, and adding to total\[$mood\] inside a loop keeps a total for every category; it needs bash 4 or newer, which on a Mac means bash 5 from Homebrew.

Source: https://www.ask-codey.com/courses/bash-in-depth/topics/bash-lists
