Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!uunet!mcsun!sunic!diab!gs From: gs@diab.se (Greger Sernemar) Newsgroups: comp.unix.wizards Subject: Re^2: awk and shell question Keywords: awk sh Message-ID: <488@diab.se> Date: 26 Sep 89 17:29:56 GMT References: <1163@ispi.UUCP> <1989Sep20.210951.10759@eci386.uucp> Organization: Diab Data AB, Taby, Sweden Lines: 33 clewis@eci386.uucp (Chris Lewis) writes: >In article <1163@ispi.UUCP> jbayer@ispi.UUCP (Jonathan Bayer) writes: >> >>HELP!! I have been pulling my hair out over this seemingly simple >>problem: >>a=" awk -F: '\$1 == \"$LOGNAME\" { >> user=\$5; >> print user >> }'" >>USER=`cat /etc/passwd | $a` >>I get the following error: >Various ugly syntax errors. Here is a solution to get parameters into an awk program: a="`awk -F: '$1 == NAME { user=$5; print user }' NAME=$LOGNAME - `" The last dash (-) closes standard input i.e enables other program to pipe to the awk script. I was forced to either supply a file name or a dash to be able to set the awk variable. I'm not sure if this is a bug in the version of awk I'm using or not. -- Greger Sernemar, Diab Data AB SNAIL: Box 2029, S-183 02 Taby, Sweden ANALOG: +46 8-7680660 EMAIL: gs@diab.se , mcsun!sunic!diab!gs