I know how to get the version for awk
on Linux: awk -W version
This doesn't work, however, on macOS.
I looked around on SO and couldn't find anything.
I also looked in the awk
man page and couldn't find anything:
$ man awk | grep version
conversion format used when converting numbers (default %.6g)
There are no explicit conversions between numbers and strings. To
awk --version
awk version 20070501
The EASY way when -v
, -V
, -version
or --version
are available (this option is available in most of cases):
awk --version
awk version 20070501
or
awk -version
awk version 20070501
Now when it is not available, we go the hard way:
whereis awk
/usr/bin/awk
then
what /usr/bin/awk
/usr/bin/awk
PROGRAM:awk PROJECT:awk-24
and
strings /usr/bin/awk | grep -Ei "version|awk"
/BuildRoot/Library/Caches/com.apple.xbs/Sources/awk/awk-24/src/b.c
version 20070501
bin/awk
-version
--version
awk %s
awkdelete
weird printf conversion %s
can't happen: bad conversion %c in format()
out of memory in awksprintf
out of memory in awkprintf
@(#)PROGRAM:awk PROJECT:awk-24
You find most all the information you were looking for by reading the strings in the binary and by using grep
to isolate what you are really looking for. (Side note you have also find out that -version
and --version
are arguments that can be used)
You can also use grep -Eai "\\bversion\\b|awk|unix" /usr/bin/awk
to reach the same result (little less readable)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.