I'm using pgrep
to find running processes having some words
> pgrep -f "otp"
2345
2343
More than one process is identified. There is another word in the command line that would help me zero in to the exact process. So, I want to search for two terms and both should be there. Unfortunately I'm only seeing examples and help for OR combinations like this:
> pgrep -f "otp|place1"
2345
2343
3632
That does not work because it's an OR condition. I need an AND condition in my search pattern.
pgrep reference: https://linux.die.net/man/1/pgrep
pattern: Specifies an Extended Regular Expression for matching against the process names or command lines.
How do I use pgrep to search for two words in AND combination instead of OR?
Best Answer
Found one way, with the condition being that they should be in order: separate the words by
.*