19

If I want to know the version of awk I get the following:

$ awk --version
awk: not an option: --version

Checking in man awk I see that my awk is

mawk - pattern scanning and text processing language

fedorqui
  • 2,027

2 Answers2

21

In this case, man awk shows us:

-W version

mawk writes its version and copyright to stdout and compiled limits to stderr and exits 0.

In my case,

$ awk -W version
mawk 1.3.3 Nov 1996, Copyright (C) Michael D. Brennan

compiled limits:
max NF             32767
sprintf buffer      2040
fedorqui
  • 2,027
6

I try to be more general.

awk -Wversion 2>/dev/null || awk --version

works whether awk invokes mawk, gawk or original-awk available for Debian/Ubuntu Linux. Note that -W and version have to be concatenated so that original-awk does not think version is a program. In Ubuntu Linux you can use sudo update-alternatives --config awk to see and to choose the implementation that is invoked by the command awk.

jarno
  • 400