bua
bua

Reputation: 4870

PCRE regular expression to match text except word group

I'm struggling to adjust my regex to filter out

from:

cat file  
user   30300 29384  0 Mar05 pts/4    00:00:00 /opt/bin/rlwrap /opt/test/l64/app apps/bin -gw :1234 -p 10006  
user   30301 30300  0 Mar05 pts/5    00:00:00 /opt/test/l64/app apps/bin -gw :1234 -p 10006  
user   30300 29384  0 Mar05 pts/4    00:00:00 /opt/bin/bash /opt/test/l64/app apps/bin -gw :1234 -p 10006 

So I need to get only second row:

grep -P 'regex' file  
user   30301 30300  0 Mar05 pts/5    00:00:00 /opt/test/l64/app apps/bin -gw :1234 -p 10006  

what I have is:

grep -P '((?:(?!rlwrap\b|bash\b).)*?)-p 10006$' file

But it doesn't work :(

I need only PCRE regex, I need to make it working withing this grep -P statement.
So please no awk, perl, sed, grep -v or similar.

EDIT
I'm really wondering why someone down-voted this question?

Upvotes: 1

Views: 1029

Answers (1)

ruakh
ruakh

Reputation: 183251

This will find all lines that don't contain /rlwrap or /bash followed by a space:

grep -P '^(?!.*/(rlwrap|bash) )' file

Upvotes: 2

Related Questions