- Article pages now have a discussion option at the bottom (moderated/captcha, but no registration needed) - recently upgraded to a newer Dokuwiki version, please report problems

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

  • terminated (broken) by the break command, optionally as break N to break N levels of nested loops
  • forced to immediately do the next iteration using the continue command, optionally as continue N analog to break N

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

Discussion

Enter your comment
 
syntax/ccmd/while_loop.txt · Last modified: 2010/04/15 20:47 (external edit)
GNU Free Documentation License 1.3
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0