Most people think the Bourne shell'slooks like this, with a single command controlling the loop:
commanddo ...whatever done
command can actually be a list of commands.
The exit status of the last command controls the loop.
This is handy for prompting users and reading answers - when the
user types an empty answer, the read command returns "false" and
the loop ends:
while echo "Enter command or CTRL-d to quit: \c" read command do ...process
Here's a loop that runs who and does a quick search on its output.
If the grep returns non-zero status (because it doesn't find
$tempfile), the loop quits - otherwise, the loop does
lots of processing:
while who > $tempfile grep "$who" $tempfile >/dev/null do ...process $tempfile... done