Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

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

Trying to understand the differences between the two functions gawk vs. awk? When would one use gawk vs awk? Or are they the same in terms of usage?

Also, could one provide an example?

share|improve this question
1  
Googling found an answer here – user13742 Jan 20 '12 at 17:03
1  
@hesse can you provide an example? – chrisjlee Jan 20 '12 at 17:04
up vote 18 down vote accepted

AWK is a programming language. There are several implementations of AWK (mostly in the form of interpreters). AWK has been codified in POSIX. The main implementations in use today are:

  • nawk (“new awk”, an evolution of oawk, the original UNIX implementation), used on *BSD and widely available on Linux;
  • mawk, a fast implementation that mostly sticks to standard features;
  • gawk, the GNU implementation, with many extensions;
  • the Busybox (small, intended for embedded systems, not many features).

If you only care about standard features, call awk, which may be Gawk or nawk or mawk or some other implementation. If you want the features in GNU awk, use gawk or Perl or Python.

share|improve this answer
1  
Actually, the BusyBox awk is pretty close in behavior to gawk v3; I think it's more full-featured than nawk. – dubiousjim Apr 19 '12 at 19:37

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.