Table of Contents

The while-loop

Synopsis

while <LIST1> ; do
  <LIST2>
done

Description

The while-loop is relatively simple in what it does: it executes the command list <LIST1> and if the exit code of it was 0 (TRUE) it executes <LIST2>. This happens again and again until <LIST1> returns FALSE.

This is exactly the opposite of the until loop.

:!: Like all loops (both for-loops, while and until), this loop can be

Return status

The return status is the one of the last command executed in <LIST2>, or 0 (TRUE) if none was executed.

Examples

Portability considerations

See also