Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!uunet!mcsun!ukc!stl!siesoft!stuart From: stuart@siesoft.co.uk Newsgroups: comp.unix.shell Subject: Re: A question on [a,ga,na]wk. Keywords: awk, gawk, nawk, csh Message-ID: <1990Dec7.172109.1411@siesoft.co.uk> Date: 7 Dec 90 17:21:09 GMT References: Sender: usenet@siesoft.co.uk (NNTP Poster) Distribution: comp.unix.shell Organization: Siemens-Nixdorf Systems Development Group, UK Lines: 36 fuchs@it.uka.de (Harald Fuchs) writes: >Solution 2, works for every awk: >Take $date out of the single quotes > #!/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. >The double quotes are not necessary, but they will be if $date contains >shell-metacharacters (e.g. spaces). My first reaction to this was that the double quotes are always necessary because otherwise awk treats it as an awk variable (if $data were "jan", say, then awk would try and match $1 with the contents of jan). I think this is true on most (if not all) versions of awk. There is however another mistake in that the single and double quotes are the wrong way round, you are telling awk that $date is a string, not csh. So it should be: ... $AWK -F: '{if ($3 == "'$date'") {print $0}}' ... >Harald Fuchs ... > *gulp* Stuart. - -- S I E M E N S Stuart Hood 65-73 Crockhamwell Road, Woodley, Berkshire, UK ------------- Phone: + 44-734-691994 Email: stuart@siesoft.co.uk N I X D O R F The trouble with everyone, is that they generalise too much