Mac OSX, Bash, awk and Negative Appearance

I want to find a specific process using awk:

ps aux|awk '/plugin-container.*Flash.*/' 

Now he finds this process, but he includes himself in the results, because the ps results also include them. To avoid this, I am trying to use a negative look:

 ps aux|awk '/(\?<!awk).*plugin-container.*Flash.*/' 

But that will not work. Does awk support? What am I doing wrong? Thanks

+4
source share
3 answers

A common trick is to use

 ps aux | grep '[p]lugin-container.*Flash.*' 

The character class [p] prevents grep from matching.

+7
source

I don't know if awk supports lookbehind, but I usually solve this problem with grep -v :

 aix@aix :~$ ps aux | awk '/plugin-container.*Flash/' | grep -v awk 

(Also, I usually used grep for the awk command above.)

+2
source

I don’t know if awk supports lookbehinds, but if, then the question mark at the beginning should not be escaped, a negative lookbehind (?<!

The question mark immediately after opening the bracket is a sign that this group is not a capture group, that is, it has some special meaning.

0
source

Source: https://habr.com/ru/post/1392461/


All Articles