Multiple templates with ack-grep?

Is it possible (and how) to associate templates with ack (ack-grep on some Linux distributions), as I'm used to grep?

eg.

grep "foo" somefile.c | grep -v "bar" 

... to match all lines with "foo" but without "bar".

+6
source share
1 answer

ack uses Perl regular expressions, and they allow viewing statements :

 ^(?!.*bar).*foo.*$ 

will match a string containing foo but not containing bar .

I am not familiar with using ack , but something like this should work:

 ack '^(?!.*bar).*foo.*$' myfile 
+10
source

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


All Articles