Working with Arrays in Bash
Store and process lists of values. Learn to declare arrays, access and iterate elements, get the length, and use associative arrays as key-value maps.
Why Arrays?
A normal variable holds one value. An array holds many — perfect for lists of files, names, or arguments you want to loop over in a script.
Declaring an Array
Create an indexed array by listing values in parentheses, separated by spaces.
fruits=(apple banana cherry)All lessons in this course
- First Bash Script & Shebang
- Variables and User Input
- Conditional Statements (if, else, elif)
- Working with Arrays in Bash