For Loop Sequence in Shell
Level 370 keystrokes
A for loop walks through the numbers produced by seq 1 2 10 (start 1, step 2, up to 10) and prints each one. After the loop, i still holds the last value, 9.
Shell code
# seq START STEP END prints 1 3 5 7 9; the loop takes them one by one1for i in $(seq 1 2 10); do # Print the current value of i2 echo "Number: $i"3done# i keeps its last value after the loop, so this prints 9 (not a sum)4echo "Total: $((i))"Output
Number: 1 Number: 3 Number: 5 Number: 7 Number: 9 Total: 9
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.
"× 4(× 3)× 3$× 3:× 2;× 1