Jump to content

While

From MattWiki

The while command continuously executes the do list as long as the last command in list returns an exit status of zero.

The until command is identical to the while command, except that the test is negated; the do list is executed as long as the last command in list returns a non-zero exit status.

The exit status of the while and until commands is the exit status of the last do list command executed, or zero if none was executed.

SYNOPSIS[edit | edit source]

while [ conditions ]; do actions; actions; done
while
>
done

Quick One Line Commands[edit | edit source]

  • list the contents of the current directory, every 60 seconds, until md5sum.md5 gets coped into the directory, when it will stop.
while [ ! -e md5sum.md5 ]; do ls -lh; sleep 60; done