Searching files on Windows is a pain. The built-in search features don’t find everything. There may be ways to make them work, but I haven’t persisted long enough to make them work.
On Linux, the combination of
grep works well, and sometimes it works on Windows using the GOW or GnuWin port of these tools. Again there may be a way to make the ported utilities work more as expected, though I haven’t found it. I suspect the problem isn’t with the tools per se but their interaction with the command line. I also tried Emacs features like
rgrep, but these features use the ported
grep utilities, and so you run into the same problems with Emacs as you do running them directly and more.
It looks like
ack is the way to go. I heard about it a long time ago and kept meaning to try it out. Now I finally did. It’s fast, convenient, etc. But here are the two things I most like about it:
- Ack works the same across platforms.
- Ack uses Perl regular expression syntax.
While the alternatives above are supposed to work the same across platforms, they don’t in my experience. But
ack does because it’s a pure Perl program. All the portability has been delegated to Perl, where it is well handled. I imagine once I become more familiar with
ack I’ll prefer it on Linux as well.
Because it’s a Perl program,
ack uses Perl regex syntax. Perl has the most powerful regex implementation out there, though I seldom need any features unique to Perl. More important for me is that Perl regular expression dialect is the one I remember most easily.
More regular expression posts
For daily tips on regular expressions, follow @RegexTip on Twitter.