Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create an infinite loop using while.
Bash Scripting
while [1]; do echo "Looping forever" done
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'false' which stops the loop immediately.
Using '0' or '1' which are not valid conditions in bash.
✗ Incorrect
The true command always returns success, so the while loop never ends.
2fill in blank
mediumComplete the code to create an infinite loop using for.
Bash Scripting
for (( [1] )); do echo "Looping forever" done
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Adding extra semicolons causes syntax errors.
Trying to put a condition that eventually ends the loop.
✗ Incorrect
In bash, for ((;;)) creates an infinite loop by omitting all three expressions.
3fill in blank
hardFix the error in the infinite loop condition.
Bash Scripting
while [ [1] ]; do echo "Looping forever" done
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '=' or '==' inside [ ] for numbers causes errors.
Using 'true' inside [ ] is invalid syntax.
✗ Incorrect
In bash test brackets, use -eq for numeric equality, so [ 1 -eq 1 ] is correct.
4fill in blank
hardFill both blanks to create an infinite loop with a condition that always succeeds.
Bash Scripting
while [1] [2]; do echo "Still looping" done
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'false' which stops the loop.
Using logical OR which may not keep the condition true.
✗ Incorrect
Using true && keeps the condition always true, so the loop never ends.
5fill in blank
hardComplete the code to create an infinite loop using a for loop with arithmetic syntax.
Bash Scripting
for (( ; [1]; )); do echo "Loop forever" done
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Putting values in init or increment that stop the loop.
Using false or invalid conditions.
✗ Incorrect
In bash, for (( ; true; )) creates an infinite loop by leaving init and increment empty and condition true.