Bird
0
0

Which of the following is the correct syntax to start a while loop in bash?

easy📝 Syntax Q3 of 15
Bash Scripting - Loops
Which of the following is the correct syntax to start a while loop in bash?
Awhile ( condition ) {
Bwhile condition then
Cwhile [ condition ]; do
Dwhile { condition } do
Step-by-Step Solution
Solution:
  1. Step 1: Recall bash while loop syntax

    Bash uses square brackets for conditions and 'do' keyword after condition.
  2. Step 2: Match syntax options

    while [ condition ]; do matches 'while [ condition ]; do' which is correct bash syntax.
  3. Final Answer:

    while [ condition ]; do -> Option C
  4. Quick Check:

    Correct while syntax = while [ condition ]; do [OK]
Quick Trick: Use 'while [ condition ]; do' to start loops in bash [OK]
Common Mistakes:
MISTAKES
  • Using parentheses instead of square brackets
  • Omitting 'do' keyword
  • Using curly braces incorrectly

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes