Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

share|improve this question
Thanks for the downvotes. Any comments about it? I guessed it can be useful for people facing the same issue, so I both posted the question and the answer. –  fedorqui Sep 18 '13 at 9:40
Did you just answer your own question saying that made up command line arguments don't work? And you just need to use a valid argument? –  50-3 Sep 18 '13 at 9:55
As you can know, --version is an almost standard command. Hence, I think it is good to show the alternative to it. –  fedorqui Sep 18 '13 at 10:02
Really? I've never once used it. Not sure it's as standard as you think it is. –  50-3 Sep 18 '13 at 10:06
Believe me it is, check man of different commands and you will find it: cp, rm, man, bash and so on. –  fedorqui Sep 18 '13 at 10:10

2 Answers 2

up vote 0 down vote accepted

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
share|improve this answer

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.

share|improve this answer
I don't know how standard it is to accept the concatenated option, but it is not necessary use it in my experience: awk -W version </dev/null 2>/dev/null|awk '{print $0;nz=1}END{if(!nz)exit 1}' || awk --version or alternatively (s=$(awk -W version </dev/null 2>/dev/null); if [ -n "$s" ]; then printf "$s\n"; else awk --version; fi) –  jarno Sep 5 at 16:39

Your Answer


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.