While Loop in Shell
Level 385 keystrokes
while loop continues executing as long as the condition is true.
Shell code
# Start the counter at 11count=1# -le means less than or equal: the loop runs while count <= 52while [ $count -le 5 ]; do # Prints Iteration: 1 up to Iteration: 53 echo "Iteration: $count" # $(( )) does integer arithmetic; without this line the loop would never end4 count=$((count + 1))5doneOutput
Iteration: 1 Iteration: 2 Iteration: 3 Iteration: 4 Iteration: 5
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.
$× 3"× 2(× 2)× 2=× 2-× 1;× 1:× 1[× 1]× 1