Patrick, On Thursday 12 August 2004 17:33, Patrick Shanahan wrote:
* Randall R Schulz
[08-12-04 19:20]: The "pidof" command is handy, too, in conjunction with all the process-oriented commands, such as ps, kill, renice, etc. I so often want to do a ps for specifically named commands I created a script to combine pidof and ps.
and a handy script 'psfind' 'ps aux|grep -i $1'
True, but the output of the pipeline includes the "grep" process itself. Another flaw is that it excludes the ps headers, which can make interpreting the output difficult, especially if you use the 'l' option. That can be overcome by using "sed" instead of grep: -==- #!/bin/bash --norc procPat="$1" ps aux |sed -n -e 1p -e "/$procPat/p" -==- But using "pidof" is still superior. You get no spurious responses, you get the ps headers and you don't need a pipeline with a filter that just discards unwaqnted ps output that is simply not produced at all using the pidof technique.
-- Patrick Shanahan
Randall Schulz