Beyond grep
I search for things a lot, especially in my code. Or even worse - someone else’s
code. For years grep
served as an amazing tool for this: fast, simple, and
yet powerful. That was until I discovered ack
for myself. An incredibly easy
to use grep
implementation built to work with large (or not really) code
trees.
A lot can be said to enforce superiority of ack
over grep
when it comes to
working with code, and it’s all said here: ack’s features.
Amazing thing is - ack
doesn’t even need a tutorial. Learning progression is
natural and “just happens” by researching necessary use cases as the need
arises (ack
has a great manual entry).
Here’s a typical use example for ack
:
ack --shell 'gr[ae]y'
Searches all shell script files in the current code tree for any occurrences of
“gray” or “grey”. It will search .sh
, .zsh
, and just about dot-anything;
ack
will even check shebang lines for you.
Ease of use, the fact that it’s ready to use out of the box, extensive file
types, native support for Perl’s regular expressions: ack
does really good
job at searching through code.
Download it from Beyond grep.
2 read-only comments
These are the read-only comments I've exported from Disqus (which I no longer use). If you'd like to share your thoughts about this article, you can ✍️ Reply by email.
Ruslan, I presume that you have also tried egrep. If so, why did you not like it? If not, please try egrep and let us know your opinion of it.
-- Paul D. Bain
Hey Paul,
I don't really have a problem with egrep in particular (egrep is just an equivalent of `grep -E` as far as I recall), it's just ack is a bit easier for working with code. Here's a list of reasons why, it would probably: http://beyondgrep.com/why-ack/ I still use grep when working on a machine without ack, and I rarely notice a lot of difference. But when I have to search for things in a code tree, with `.git` directories, `tags` files, and other junk I can just ignore in `.ackrc` -- ack is just easier.