Associative Arrays: Lists with Names

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.

Updated

Cheat sheet for the lesson Associative Arrays: Lists with Names: 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…
Category
Bash
Level
Freelancer
Tags
associative-array, declare, homebrew, key-value-pair, linux, unix