tags:

views:

85

answers:

1

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?

A: 

The first one is ignoring both because they both have 'data' as a sub-directory and ack searches sub-dirs by default. So it will ignore any sub-dir with that name. Unfortunately, your second way doesn't work either. This works for me:

ack -a searchtext -G '^(?!.*secondary/data.*).*$'

Instead of -a to search all files, see ack-grep --help=types to search for only certain file types, eg --type=text

rkulla
Thanks for the response. I'm getting this: $ ack-grep --text -G '^(?!.*secondary/data.*).*$' ack-grep: No regular expression found.
mattalexx
that's because you forgot to give it the pattern you're grepping for, ie 'searchtext'
rkulla