Grep process with two strings

Hi,
I am trying to get the PID of a process that is defunct. I have two quesitons on this.

1) how do I pass in two strings? This is what I am using now:

ps -ef |egrep -i "programname|<defunct>"

But this returns multiple results with the word defunct in them.

2) How do I make it so that my egrep does not show up in my results?

Thanks for your help.

Hi.

You probably just want one string as a regular expression:

For example:

ps -ef | grep -i "[p]rogramme.*<defunct>"

( [p] will prevent grep from showing up in the results)

1 Like