I'm trying to search my entire server for a string, whilst excluding dev/ (-R) using ack. So far I have
sudo ack -i --ignore-dir=dev * foo
--version ack v1.39
But I'm getting an error. Where am I going wrong?
Any help or advice on this matter is welcome
First, whenever you say "I'm getting an error", change that to "I am getting the following error" and then tell us what the error is. The error is important for us to be able to help diagnose the problem.
Second, the version of ack you're using is very old. The latest is 1.96.
Third, you have your arguments out of order. You're searching for "foo", right? Then you should be doing "ack foo *", not "ack * foo".
You shouldn't be specifying "*" for a filename. Let ack do the file finding for you. If "dev" is a directory in the directory you're calling from, then "ack *" will expand to "ack dev [other directories]", which is explicitly telling ack to search in the "dev" directory, which overrides the --ignore-dir
directive.
What you should be doing is:
ack -i --ignore-dir=dev foo
And then you let ack do the file finding. You should only specify filenames on the command line if for some reason you have to override the files that ack
is finding.
Finally, you probably shouldn't even be using ack for this task in the first place. ack is specifically for searching source code, and it won't search files that it doesn't consider source code. If you are searching the entire server, then you probably want to be searching non-source code files, too, right? Use grep for this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With