2

I am reading through awk here but I am just wondering about the awk versions as I have encountered issues before with different awks. Below is a look at the different version I have. As I understand it there is awk, mawk and gawk. With gawk being the newest/better. Can anyone clarify my assumptions? I s GNU Awk 4.1.1 the newest and best to be using i.e. is it gawk? Any other comments on the different versions?

env1 - cygwin on my pc

$ awk -Wversion 2>/dev/null || awk --version
GNU Awk 4.1.1, API: 1.1 (GNU MPFR 3.1.2, GNU MP 6.0.0)
Copyright (C) 1989, 1991-2014 Free Software Foundation.

env2 - a docker container

$ awk -Wversion 2>/dev/null || awk --version
mawk 1.3.3 Nov 1996, Copyright (C) Michael D. Brennan

EDIT1

as per the comment click on the tags for awk, gawk and mawk
gawk (short for GNU awk) is a free implementation of awk with manifold useful extensions.
Mawk is an implementation and fast processor of the AWK programming language.
AWK is an interpreted programming language designed for text processing and typically used as a data extraction and reporting tool. Use this tag only if your question relates to programming using awk or awk-based APIs. Questions relating to using or troubleshooting awk command-line options itself are off-topic.

HattrickNZ
  • 4,373
  • 15
  • 54
  • 98

1 Answers1

3

A basic specification of awk would be the POSIX one that is described here: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/awk.html

But there are other implementations of awk that do not adhere to the POSIX specification; either because they miss features, add new ones or behave differently.

For instance in this page for gawk you can read about its divergencies from the POSIX specification (e.g. is some cases to get a fully POSIX behavior the --posix option shall be passed in the command line): https://www.gnu.org/software/gawk/manual/html_node/POSIX_002fGNU.html

You mention gawk or mawk; but other vendors also provide their own awk implementation as those found in Mac OS X (BSD implementation), Oracle Sun Solaris, IBM AIX, HP-UX and so on.

About your question on which is the best one: I guess this would be too a subjective response.

From a practical point of view I would simply use the system's awk and in the case I find that too limiting or different from what I expect, I would go on and run gawk instead.