Multiple choice technology

What is the syntax of the while loop written in a single line?

  1. while command do list ; done

  2. while command ; do list

  3. while command ; do list ; done;

  4. while command ; do list ; done

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

The correct single-line while loop syntax in shell is 'while command ; do list ; done'. The semicolons allow placing the do and done keywords on the same line as commands. Option D has the proper syntax with semicolons in all required positions. Options A and C are missing semicolons, while B is missing 'done'.