I'm using ack (sometimes distributed as ack-grep) to search through a complex directory of code, images, who knows what else, and it's reacting pretty slowly. How can I diagnose what it is searching through that is making it slow, so that I can have it ignore 'em?
I just realized that the reasons that my ack-grep are slow will probably make grep slow for the same reason, so I've changed the wording of the title to refer to both.
Current ack-grep command alias:
function view ()
{
echo "ack-grep -i $@ // ignoring third-party directories"
ack-grep -i --ignore-dir=third-party --ignore-dir="unclean-files" --ignore-dir=FCKeditor --ignore-dir=smarty --ignore-dir=codepress --ignore-dir=yui "$@"
}
So I do a case-insensitive search on some string via that alias, e.g. view "Oops! Required fields"
, ignoring certain directories.
I guess what I could really use is a "verbose" mode to either grep or ack-grep, so that I can visually see subdirectories that it hangs around on because they're slow to search.
Ended up using the -L switch to make it output all the files that it matches, for quick visual diagnosis of problems. Used just the command structure below:
ack-grep -L "Oops! Required fields were not all completed."
What are you searching for? If it's just source of a particular type (say you're looking for a variable), use the appropriate switch (for perl, use --perl, etc). If you have tons of source, it's gonna take a while regardless of what you do.
Ack-grep is only as smart as you tell it to be. Also, how complex is your regex? Regex has overhead, and if you're just searching for a name of something, don't use regex. You shouldn't use a hammer to loosen a bolt.
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