Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 10-09-2003, 09:41 PM   #1
Registered: Aug 2003
Posts: 57

Rep: Reputation: 15
Quick grep question

How do I get grep to match a line that contains one thing and not another? I need to grep the output of ps to make sure that DHCPd is running, but sometimes "grep dhcpd" will show up as its own process, thus throwing off grep. For some reason the following comes to mind:

ps -aux |grep "^(grep) dhcpd"
However, the caret is functioning as an anchor, not as a logical-NOT operator. Help would be greatly appreciated.
Old 10-09-2003, 11:38 PM   #2
Senior Member
Registered: Feb 2003
Location: N'rn WI -- USA
Distribution: Kubuntu 8.04, ClarkConnect 4
Posts: 1,142

Rep: Reputation: 47
You can run it through grep again with the -v option... It selects the non-matching lines...

ps -aux | grep dhcpd | grep -v grep
Old 10-10-2003, 06:38 AM   #3
Registered: Aug 2003
Posts: 57

Original Poster
Rep: Reputation: 15
Thanks... that's probably simpler than doing it in one regexp.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
quick grep question provkitir Linux - Software 4 11-25-2004 09:32 PM
grep question djgerbavore Linux - Newbie 3 11-04-2004 10:53 AM
Question about Grep irfanhab Linux - Newbie 6 08-23-2004 02:57 PM
grep question vasanthraghavan Programming 3 04-23-2004 12:32 AM
grep question keyops Programming 2 04-09-2004 09:17 PM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 11:26 AM.

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