Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Does the do... while loop work in the original awk? Or has it been introduced in later implementations (nawk, gawk, ...)? Can nawk be considered present on all Unix platforms today?

Greets, Oliver

share|improve this question
Sounds like a homework question. – Coops Dec 1 '09 at 11:02
Nope, actually I'm learning awk and I wanted to write down a small tutorial for myself but most of the tutorials i found on the web focus on [gmn]awk without mentioning it... – Trollhorn Dec 1 '09 at 11:08

The do while loop is documented in Solaris (o)awk so likely predates the newer [gn]awk standard.

I believe all current Unix/Unix like platforms provide either gawk, nawk or a compliant awk.

share|improve this answer

Per page 49 of The AWK Programming Language book by Aho, Weinberger, and Kernighan (the AWK), it should.

I've not seen a modern UNIX variant that didn't provide nawk, however.

share|improve this answer

According to info gawk in Appendix A, Section 1 "Major Changes Between V7 and SVR3.1":

The `awk' language evolved considerably between the release of Version 7 Unix (1978) and the new version that was first made generally available in System V Release 3.1 (1987). This minor node summarizes the changes, with cross-references to further details:

  • The `do'-'while' statement
share|improve this answer

It should be there. If you want to use ancient awk, run gawk with the --traditional option.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.