Awk with passed parameters

Jonathan I. Kamens jik at athena.mit.edu
Mon Mar 11 09:54:14 AEST 1991


In article <1991Mar08.141340.26881 at convex.com>, tchrist at convex.COM (Tom Christiansen) writes:
|> The first thing is that you need to put your variable assignments
|> in front of your program.  You probably should protect your string
|> literals with double quotes so it doesn't think they are variables.

  This is not true.  Awk reads variable assignments in "file arguments" and
does the assignments *before* the main body of the awk program is executed. 
The only problem with the program as originally posted was that he needed to
add "-" to the end of the awk command to tell it to read from stdin after
reading the other "file arguments" (which were actually variable assignments).

  If he adds that dash, then things should work on virtually any version of
awk, since variable assignments in file arguments were supported in very early
versions of awk and have continued to be supported in most versions.  Tom, do
you know of a version of awk which won't work properly if an extra file
argument of "-" is added to the end of the awk command?

-- 
Jonathan Kamens			              USnail:
MIT Project Athena				11 Ashford Terrace
jik at Athena.MIT.EDU				Allston, MA  02134
Office: 617-253-8085			      Home: 617-782-0710



More information about the Comp.unix.shell mailing list