Arrays in Bash
Real lists, if you quote them right.
langs=(bash python rust)
langs+=(go)
echo "count: ${#langs[@]}"
echo "first: ${langs[0]}, last: ${langs[-1]}"
# "${arr[@]}" expands one word per element -- the quoting matters
for lang in "${langs[@]}"; do
echo "- $lang"
done
How it works
(a b c)builds;+=appends;${#langs[@]}counts.[-1]reads from the end."${langs[@]}"expands one word per element — the quotes matter.
Keywords and builtins used here
dodoneechoforin
The run, in numbers
- Lines
- 10
- Characters to type
- 227
- Tokens
- 51
- Three-star pace
- 75 tpm
At the three-star pace of 75 tokens a minute, this run takes about 41 seconds.
Step 1 of 3 in Arrays, step 10 of 26 in Language basics.