Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!elroy.jpl.nasa.gov!turnkey!orchard.la.locus.com!fafnir.la.locus.com!fafnir.la.locus.com!richard From: richard@locus.com (Richard M. Mathews) Newsgroups: comp.unix.aix Subject: Re: Easy(?) problem for shell script writers Message-ID: Date: 11 May 91 00:41:46 GMT References: <1991May9.151138.21246@uvm.edu> <28614@hydra.gatech.EDU> Organization: Locus Computing Corporation, Los Angeles, California Lines: 33 scott@prism.gatech.EDU (Scott Holt) writes: >moore@emily.uvm.edu (Bryan Moore) writes: >>I want to do a 'ps | fgrep $1' where $1 is each of the above >>strings, but obviously the above is incorrect. >sounds like you want something to the effect of: >PARAMETERS=`awk ...` - those are accent characters >if [ "$PARAMETERS" ] >then > for i in $PARAMETERS > do > ps | fgrep $i > done >else > echo "Awk found nothing" >fi But do you really want to run "ps" repeatedly for each string? And do you want a line of "ps" output to be printed multiple times if more than one string appears in that line? How about: awk ... > /tmp/foo.$$ ps | fgrep -f /tmp/foo.$$ rm -f /tmp/foo.$$ (or set up a "trap" to do the "rm", so the temp file gets removed even if the script is killed by a signal). Richard M. Mathews Freedom for Lithuania richard@locus.com Laisve! lcc!richard@seas.ucla.edu ...!{uunet|ucla-se|turnkey}!lcc!richard