On Wed, Mar 20, 2002 at 12:11:30AM +0000, Ronan Waide wrote:
> > Yes, Dave gets the banana for sure on that one, provided that that set of ps
> > options work next week/distro/version/whatever :-)
>> which is why I prefer my kill -0 option, to be honest.
My ps version works fine, but I was just about to change to the kill -0 way
when I thought of PID reuse - a small error possibility, but definitely
there, so I'm sticking with ps and for that I have a question. There've been
a couple of suggestions of using an RE to grep as in this from Paul
[root at dunlop modules]# ps ax | grep foo
14801 pts/0 S 0:00 grep foo
[root at dunlop modules]# ps ax | grep [f]oo
[root at dunlop modules]#
What is it about grep and RE that causes this behaviour ? (note that the
above example is not always correct. For example,
niall at bagend:~ >ps -ax|grep [f]oo
1944 pts/8 S 0:00 grep foo
but if you ensure that grep sees the RE like this
niall at bagend:~ >ps -ax|grep "[f]oo"
niall at bagend:~ >
it's fine)
Does grep manipulate its arguments as saved or what ? Because I called my
script ssh-agent-setup I matched on "$USER.*ssh-agent$" and that works also
(i.e. ps|grep doesn't find the grep) but leaving out the $ doesn't work
james at bilbo:~> ps aux|grep "${USER}.*ssh-agent$"
james 1264 0.0 0.3 2016 740 ? S 09:16 0:00 ssh-agent
james at bilbo:~> ps aux|grep "${USER}.*ssh-agent"
james 1264 0.0 0.3 2016 740 ? S 09:16 0:00 ssh-agent
james 1313 0.0 0.3 1612 588 pts/0 S 09:27 0:00 grep james.*ssh-agent
james at bilbo:~>
So, ps|grep won't match the grep when grep uses certain kinds of RE - oh
lordy ! I'm leaving my grep -v grep in, thank you, in case the kind of RE is
dependent on the phase of the moon :-)
Niall
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!