LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 03-28-2004, 12:02 AM   #1
QtCoder
Member
 
Registered: Aug 2003
Location: USA
Distribution: Slackware 12.0 RC1
Posts: 129

Rep: Reputation: 15
Unhappy How can I filter the output of grep to exclude certain cases?


Hello.

I am in the process of writing a little script to automate my use of 3d-desktop (a nifty little eye-candy app) The script involves checking to see if 3ddeskd is running. So, I test the condition with `ps -e | grep 3ddeskd'. However, ps -e (or any other combo of args like ax) will also echo defunct processes. 3d-desktop tends to zombify sometimes (I don't know why), so in my test condition in the script, the test passes if grep sees "3ddeskd <defunct>". This is not acceptible. The condition should only pass if 3ddeskd is actually running.

So, my questions are:

Can one remove a defunct process without killing its parent? (this would be useful in many situations). If not, how could I filter the output of `ps -e | grep 3ddeskd' to include only the running 3ddeskd, if it exists?

I've tried using regex's in the argument to grep, but none have worked. Perhaps my bash regex skills are not very good.

Any help is appreciated.

Thanks
 
Old 03-28-2004, 12:05 AM   #2
QtCoder
Member
 
Registered: Aug 2003
Location: USA
Distribution: Slackware 12.0 RC1
Posts: 129

Original Poster
Rep: Reputation: 15
BTW,

I know I could spend a couple extra minutes writing another if-statement or two to deal with the defunct 3ddeskd, but I'm lazy. Actually, I think it's best to learn another way.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Using find and grep - how to exclude a result ? graziano1968 Linux - General 13 12-04-2010 10:02 PM
[SOLVED] grep exclude Manuel-H Linux - General 4 10-12-2010 08:50 PM
how to filter output from passwd file mussussu Linux - General 2 11-28-2005 04:17 PM
Grep-like filter exists? carl.waldbieser Programming 3 08-31-2005 11:34 PM
Need help with grep, trying to parse/filter a file... patsnip Programming 4 08-29-2003 02:33 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 05:54 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration