An additional monkey wrench in the works.
program is named after its authors, Alfred Aho, Peter Weinberger and Brian Kernighan all at the time of AT&T Bell Laboratories. The original awk
dates from a long, long time ago (1977). New awk
was released in conjunction with Aho et. al. The AWK Programming Language
(Redding, MA: Addision-Wesley Publishing Co., 1988), ISBN 0-203-07981-X. New AWK, called nawk
, is completely documented in this book. As to the differences, the preface, pp. v-vi briefly outlines:
Evolution of the AWK Language
The major new feature is the ability for users to define their own functions. Other enhancements include dynamic regular expressions, with text substitution and pattern-matching functions: additional built-in functions and variables; some new operators and statements; input from multiple files; and access to command-line arguments. Error messages have also been improved..."
Because Solaris adheres pretty much to System V Release 4 (with Berkeley enhancements), it contains both the original AWK oawk
. The gawk
program is a GNU implementation of nawk
(as I understand it) with additional
enhancements, many of which are not compatible with nawk
, and, gawk
is what you get with Linux.
My own experience has been that going from Linux to Solaris can sometimes be a royal pain where you sit and I have learned (the hard way, as usual) to avoid GNU-specific enhancements to any language implementation, not just AWK. I have the source code for nawk
and run it on my Linux boxes just to avoid those kind of problems and life is better.
Is there any "best?" Well, best is a relative term. In my book, best means no problems porting high-level software from one platform to another and that means avoiding enhancements because they will always
come back and bite you in the butt (that was learned the hard way porting DEC FORTRAN programs -- chock full of DEC's enhancements -- to System V). If you find a copy of the book and adhere to the grammar and syntax therein you'll probably not have a problem with gawk
on Linux and nawk
on Solaris. Personally, on Solaris, I write in nawk
grammar and syntax to take advantage of the authors' enhancements from oawk
; and, you probably won't have gawk
available on a Solaris box out of the carton (system administrators where I get paid are really leery of wily-nilly installing GNU utilities because of past compatibility problems that nobody really wants to spend time dealing with when an analog is sitting there to begin with).
For what it's worth...