1

I love ack.

I need to search for 'foo' in all the files except the test files.

ack has option -G to specify regex. However I am not sure how do I write regex for the condition that look for all files but ignore files with word 'test'.

Nick Vanderbilt
  • 36,724
  • 29
  • 83
  • 106

2 Answers2

0
^(?!.*test.*).*$
Jeff
  • 21,744
  • 6
  • 51
  • 55
0

Starting with ack 2.0, you need to specify a file type and then filter based on it. In this case, you want to skip files with the word test in them:

ack --type-set testfiles:match:'test' --type=notestfiles pattern

Note: I'm using the negative of the file type testifies, so I've appended no to filetype, as per the documentation:

--type=noX Exclude X files. See "ack --help-types" for supported filetypes.

gregory
  • 10,969
  • 2
  • 30
  • 42