Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site utcs.uucp Path: utzoo!utcs!onn From: onn@utcs.uucp (Brian Onn) Newsgroups: net.unix Subject: Re: passing command line arguments to awk Message-ID: <1261@utcs.uucp> Date: Fri, 30-May-86 20:41:45 EDT Article-I.D.: utcs.1261 Posted: Fri May 30 20:41:45 1986 Date-Received: Fri, 30-May-86 21:20:36 EDT References: <198@comp.lancs.ac.uk> Reply-To: onn@utcs.UUCP (Brian Onn) Distribution: net Organization: University of Toronto Computing Services, general purpose UNIX Lines: 33 Summary: In article <198@comp.lancs.ac.uk> craig@comp.lancs.ac.uk (Craig Wylie) writes: > >I surrender -- is it possible to pass command line arguments to awk? > >If so - how. While I'm at it how about doing the same thing to sed. > > >Craig. The only way I know of to pass command line arguments into awk is by defining them as variables in an assign statement on the awk command line, ie awk -f awkfile arg1=$1 arg2=$2 inputfile will assign $1 to arg1, and $2 to arg2, inside the body of the awk program. It is not possible to assign variable values in this manner to variables that are used inside an action associated with the BEGIN pattern. I am not sure how to do it with sed. -- ----- Brian A. Onn University of Toronto Computing Services Erindale College. ..!{ihnp4,decvax,harpo,utcsri,{allegra,linus}!utzoo}!utcs!onn "We trained hard, but it seemed that every time we were beginning to form up into teams, we would be reorganized. I was to learn later in life we tend to meet any new situation by reorganizing, and a wonderful method it can be for creating the illusion of progress while producing confusion, inefficiency and demoralization" - Petronius Arbiter, 66 AD.