LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Quick grep question (https://www.linuxquestions.org/questions/linux-software-2/quick-grep-question-102314/)

player_2 10-09-2003 10:41 PM

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:

Code:

ps -aux |grep "^(grep) dhcpd"
However, the caret is functioning as an anchor, not as a logical-NOT operator. Help would be greatly appreciated.

ranger_nemo 10-10-2003 12:38 AM

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

ps -aux | grep dhcpd | grep -v grep

player_2 10-10-2003 07:38 AM

Thanks... that's probably simpler than doing it in one regexp.


All times are GMT -5. The time now is 03:47 PM.