Ashish Shukla आशीष शुक्ल <[EMAIL PROTECTED]> writes:
> >>>>> "Puneet" == Puneet Lakhina <puneet.lakhina <at> gmail.com> writes: > Puneet> Hi, > Puneet> I have to frequently find the process ids of particular processes using a > Puneet> combination of ps and grep. > > You can try 'pidof'[1], if you're simply interested in find pid of a > process :) > > [snipped] > > Puneet> But I was wondering if there was a way for me to specify this in the regular > Puneet> expression for the first grep itself. > > Puneet> I tried ps -elo pid,args|grep "myprocess\\!(grep)" > > The argument of grep is a regular expression (type 3 language), and > there is no way you can do this in a type 3 language. Even 'grep' also > matches 'grep' text when you pass '-v grep' argument to 'grep' command > line, and then only outputs unmatched lines. Type 3 and all that: reference: http://en.wikipedia.org/wiki/Regular_language Makes my eyes glaze over. And ps output formats confuse me (see the man page if you want to make your eyes froth and bleed like in a horror movie). Puneet, with GNU ps what you're trying to do might be done by: ps -A | grep myprocess and if you really want to use the elo options (using that makes my GNU ps barf so I haven't tested it), then maybe stick [] around the first character in myprocess (ie, make it: [m]yprocess, see if that does the job): ps -elo pid,args | grep [m]yprocess I don't think there's a restriction on excluding the inclusion of grep in a grep based on it being type 3. YMMV PJ PS: pgrep, pkill, pidof (like others have said) may be handier for your needs. _______________________________________________ ilugd mailinglist -- ilugd@lists.linux-delhi.org http://frodo.hserus.net/mailman/listinfo/ilugd Next Event: http://freed.in - February 22/23, 2008 Archives at: http://news.gmane.org/gmane.user-groups.linux.delhi http://www.mail-archive.com/ilugd@lists.linux-delhi.org/