Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!rpi!crdgw1!sixhub!davidsen From: davidsen@sixhub.UUCP (Wm E. Davidsen Jr) Newsgroups: comp.unix.shell Subject: Re: A question on [a,ga,na]wk. Keywords: awk, gawk, nawk, csh Message-ID: <2539@sixhub.UUCP> Date: 9 Dec 90 02:29:50 GMT References: <1990Dec7.172109.1411@siesoft.co.uk> Reply-To: davidsen@sixhub.UUCP (bill davidsen) Distribution: comp.unix.shell Organization: *IX Public Access UNIX, Schenectady NY Lines: 30 I missed the first part of this, but in general you can't use shell variables in ' quotes because they don't get expanded. This fails: awk '/$1 == $date/{ print $4 }' file These work: awk "/\$1 == $date/{ print \$4 }" file awk '/$1 == date/{ print $4}' date=$date file The first allows substitution of the $date, but uses escapes to pass the $ to awk (and you need escapes for any " quotes, too. The second is the better way to do it, by defining an awk variable on the command line. NOTE: some versions of awk will not accept command line definitions unless there is a filename. If you are reading stdin you must put a - in for the filename: something | awk '/$1 == date/{ print $4}' date=$date - I hope that's what people were trying to say, the original question is either behind the answers or very old. I have 10 days spooled and I don't have it. -- bill davidsen - davidsen@sixhub.uucp (uunet!crdgw1!sixhub!davidsen) sysop *IX BBS and Public Access UNIX moderator of comp.binaries.ibm.pc and 80386 mailing list "Stupidity, like virtue, is its own reward" -me