Grep and ps, exclude grep itself

By neokrates, written on June 22, 2010

bash   snippet

  • Join date: 11-30-99
  • Posts: 224
View Counter:
  • 127 views
Rate it
Ad
Poll
  • How does version control (VCS) work in your enterprise?

    View Results

    Loading ... Loading ...
Feeds:
  • bodytext bodytext bodytext

If you write a shell script, you sometimes wish to rely on the process running or not running. If you just combine grep and ps to detect that some process is running, you will always get ‘some’ output.
The grep itself, if nothing else. Use -v- option to reverse criteria (show all but nothing what is ‘grep’):

ps -ef|grep firefox|grep -v grep
Be Sociable, Share!
 
Does that help to solve your problem?
VN:F [1.8.5_1061]
Rating: +1 (from 5 votes)
3 votes 'YES'  2 votes 'NO'
TAGS
No tags for this post.
RELATED
Pages
Posts
SOCIAL
Be Sociable, Share!

Leave a Reply