24

I have certain CSS files of fileName *-c.css and *-gen.css which I want to ignore from ack-grep searches.

I see that --type-set=TYPENAME=.extension does not accept regex filters like *-c.css, any idea of how to get around this problem ?

2 Answers 2

44

I came across ack-grep 2.0 which provides --ignore-file option based on regex pattern as below and it worked after adding it to ~/.ackrc.

--ignore-file=match:-c.js
--ignore-file=match:-gen.js
--ignore-file=match:-c.css
--ignore-file=match:-gen.css
3
  • 17
    for exact file names: --ignore-file=is:<filename> - for ctags file: --ignore-file=is:tags
    – mMontu
    Oct 24, 2013 at 12:18
  • Filters for different uses can be found on beyondgrep.com/documentation/…
    – mMontu
    Oct 24, 2013 at 12:24
  • 5
    For all the too-fast readers finding this: Note that the '-' in the match string above is not saying "remove c.js files" - the '-' is part of the file name in the original question!
    – Ross R
    Jan 23, 2017 at 14:16
1

Use a regular expression to filter those files you want to search.

ack -G '(?<!-c)(?<!-gen)\.css$' expression_to_search

It uses the perl flavour. I do a negative look-behind to skip those that contain -c or -gen just before the extension.

1
  • For those reading this in 2019 or beyond, ack 3.x doesn't support the -G option. You have to use ack -g pattern | ack -x expression_to_search. Sep 4, 2019 at 4:35

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.