Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!sol.ctr.columbia.edu!emory!audfax!arnold From: arnold@audiofax.com (Arnold Robbins) Newsgroups: comp.unix.shell Subject: Re: A question on [a,ga,na]wk. Keywords: awk, gawk, nawk, csh Message-ID: <308@audfax.audiofax.com> Date: 30 Nov 90 19:39:19 GMT References: Distribution: comp.unix.shell Organization: AudioFAX, Inc., Atlanta Georgia Lines: 28 In article bt00@PL118d.? (Binod K. Taterway) writes: >Is it possible to make use of c-shell variables in [g,n]awk scripts. >What I need to do some thing like this: > > #!/bin/csh > set AWK=/usr/local/bin/gawk > set date=`date +%m/%d/%y` > # Now the awk script that uses $date: > $AWK -F: '{if ($3 == $date) {print $0}}' > # End of shell script. You can do variable assignments to awk variables on the command line. The behaviour is most consistent with gawk and very recent versions of nawk, but this should work with all awk variants: set date=`date +%m/%d/%y` $AWK -F: '{if ($3 == date) {print $0}}' date="$date" Of course, your awk program might better be written as $AWK -F: '$3 == date' date="$date" See the gawk manual for full details on the way the awk command line works. -- Arnold Robbins AudioFAX, Inc. | Laundry increases 2000 Powers Ferry Road, #200 / Marietta, GA. 30067 | exponentially in the INTERNET: arnold@audiofax.com Phone: +1 404 933 7612 | number of children. UUCP: emory!audfax!arnold Fax-box: +1 404 618 4581 | -- Miriam Robbins