Xref: utzoo comp.unix.questions:29329 comp.unix.shell:1654 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!snorkelwacker.mit.edu!bloom-picayune.mit.edu!athena.mit.edu!jik From: jik@athena.mit.edu (Jonathan I. Kamens) Newsgroups: comp.unix.questions,comp.unix.shell Subject: Re: Awk with passed parameters Keywords: awk bsd shell Message-ID: <1991Mar10.235414.28125@athena.mit.edu> Date: 10 Mar 91 23:54:14 GMT References: <3022@dsacg3.dsac.dla.mil> <1991Mar08.141340.26881@convex.com> Sender: news@athena.mit.edu (News system) Organization: Massachusetts Institute of Technology Lines: 22 In article <1991Mar08.141340.26881@convex.com>, tchrist@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@Athena.MIT.EDU Allston, MA 02134 Office: 617-253-8085 Home: 617-782-0710