Array Basics in Shell
Level 358 keystrokes
Arrays store multiple values and can be iterated with for loops.
Shell code
# Creates an indexed array of five elements (bash)1nums=(10 20 30 40 50)# ${nums[@]} expands to every element; quoting it ("${nums[@]}") keeps elements with spaces whole2for n in ${nums[@]}; do # Prints one value per line: 10 to 503 echo $n4doneOutput
10 20 30 40 50
Practice typing this code. Results are not recorded in the rankings.
Symbols in this code
The symbols you type in this Shell code and how often they appear.
$× 2;× 1(× 1)× 1[× 1]× 1{× 1}× 1@× 1=× 1