Complete the code to print numbers from 1 to 5 using a while loop.
#!/bin/bash count=1 while [ $count [1] 6 ] do echo $count ((count++)) done
The operator -lt means "less than" in bash. The loop runs while count is less than 6.
Complete the code to stop the loop when the user enters 'exit'.
#!/bin/bash input="" while [ "$input" != "exit" ] do read -p "Type something (or 'exit' to quit): " [1] done
The variable input stores what the user types. The loop checks if input is not 'exit'.
Fix the error in the loop condition to correctly check if count is less than or equal to 10.
#!/bin/bash count=1 while [ $count [1] 10 ] do echo $count ((count++)) done
The operator -le means "less than or equal to" in bash, which matches the requirement.
Fill both blanks to create a loop that prints even numbers from 2 to 10.
#!/bin/bash num=2 while [ $num [1] 10 ] do echo $num num=$((num [2] 2)) done
The loop runs while num is less than or equal to 10 (-le). We add 2 each time (+) to get even numbers.
Fill all three blanks to create a loop that counts down from 5 to 1 and prints each number.
#!/bin/bash count=5 while [ $count [1] 0 ] do echo [2] count=[3] done
The loop runs while count is greater than 0 (-gt). We print $count and then subtract 1 each time ($((count - 1))).