Your Question: What Is the Do While Command in Linux?
Contents

while command in Linux is used to repeatedly execute a set of command as long as the COMMAND returns true. The test command is given and all other commands are executed till the given command’s result satisfies, when the command’s result become false, the control will be out from the while command.

What is the do while Shell command?

Shell Script While Loop Examples

  • while [ condition ] do command1 command2 commandN done.
  • while [[ condition ]] ; do command1 command1 commandN done.
  • while ( condition ) commands end.
  • #!/bin/bash c=1 while [ $c -le 5 ] do echo “Welcone $c times” (( c++ )) done.

How do you do a while loop in shell script?

Syntax. Here the Shell command is evaluated. If the resulting value is true, given statement(s) are executed. If command is false then no statement will be executed and the program will jump to the next line after the done statement.

Maya Lin-Takahashi

Maya Lin-Takahashi

Consumer Tech & Gadget Reviewer

Maya is a hardware enthusiast who tests and reviews smart home devices, smartphones, wearables, and audio gear. She focuses on practical consumer value and build quality.

Share this article
Twitter Facebook Pinterest