Path: utzoo!news-server.csri.toronto.edu!rpi!usc!elroy.jpl.nasa.gov!sdd.hp.com!think.com!snorkelwacker.mit.edu!bloom-picayune.mit.edu!athena.mit.edu!jik From: jik@athena.mit.edu (Jonathan I. Kamens) Newsgroups: comp.unix.questions Subject: Re: awk script Keywords: awk, ps, kill Message-ID: <1991Mar18.193118.17247@athena.mit.edu> Date: 18 Mar 91 19:31:18 GMT References: Sender: news@athena.mit.edu (News system) Organization: Massachusetts Institute of Technology Lines: 26 In article , drears@pilot.njin.net (Dennis G. Rears) writes: |> CMD='artemis' |> ME=`whoami` |> PROC=`ps -ef|grep /${CMD}| \ This seems like a problem to me. Programs in a ps listing don't always have the full path of the executable listed. With the slash in the command above, you're requiring the full path listing, which is probably going to lose in some cases. |> awk '{ $1 == ${ME} && $8 != "grep" $2 }' ` First of all, the conditions should be outside the curly braces. Second, you can't just give a field and expect awk to print it -- you have to tell awk to print it. Third, few versions of awk allow you to access environment variables inside awk, and that's what you're trying to do above, since the ${ME} inside the single quotes is going to be interpreted by awk, not by the shell. Try this: awk '$1 == '${ME}' && $8 != "grep" {print $2}'` -- Jonathan Kamens USnail: MIT Project Athena 11 Ashford Terrace jik@Athena.MIT.EDU Allston, MA 02134 Office: 617-253-8085 Home: 617-782-0710