ack: Excluding only one directory but keeping all others with the same name

ack
mattalxndr picture mattalxndr · May 10, 2010 · Viewed 18.9k times · Source

My folder structure looks like this:

/app
/app/data
...
/app/secondary
/app/secondary/data

I want to recursively search /app, including /app/data. I do not want to search /app/secondary/data however. This what I have so far:

ack --ignore-dir=data searchtext
ack --ignore-dir=secondary/data searchtext

The first command is ignoring both directories and the second one is ignoring neither of them. From within the app folder, what should my ack command look like?

Answer

Erin Heyming picture Erin Heyming · Feb 7, 2012

The older versions of ack can only take the folder name, not the folder path. As of version 1.93_02, they've added this ability in:

1.93_02     Wed Oct  6 21:39:58 CDT 2010
   [ENHANCEMENTS]
   The --ignore-dir option now can ignore entire paths relative
   to your current directory.  Thanks to Nick Hooey.  For example:

       ack --ignore-dir=t/subsystem/test-data

(From betterthangrep.com/Changes)

You can check which version you have with --version:

ack --version