Array
A collection of values.
Syntax
name=(e1 e2 e3)
Description
Defined with parentheses, separated by spaces. ${name[0]} is the first element, ${name[@]} is all of them, ${#name[@]} is the number of elements.
Example
Loading editor…
Expected output
red 3
When to use?
Storing lists.
Common mistakes
- ⚠️ Elements are separated by spaces, NOT commas: (a b c).