Drupal filetypes for Ack grep.

How often did I not think "sigh, I wish I could just grep this pile of invoices for that date". But unfortunately, the all-powerfull search-tool grep is not available IRL. But it is available on most unices, including all Linux systems and OSX.

But life gets even better. With Ack-grep. A much faster, better and more targeted tool. For example , it will ignore all sorts of files you usually wanted to ignore, when "grepping" trough a pile of files. You know, searching for that line "sent to foo@example.com", but getting all sorts of results from backup files, revision-databases and what more. Ack does this. And more.

Ack also allows you to define profiles. Sets of files to be searched trough and sets of files to ignore. It comes with lots of built in sets, but not with Drupal predefined.

To get a Drupal profile, just add a .ackrc file to your home directory and add the profiles there.

echo "--type-set=drupal=.php,.inc,.module,.install,.info,.engine" >> ~/.ackrc

Now you can search trough Drupal with

ack "implementation of hook_"

Or, if you want to ignore all none-drupal(ish) files, with

ack --drupal "implementation of hook_"

Or, if you want to search trough all files, except Drupal-files

ack --nodrupal "Licence"

Many additional tools, such as gedit addons, will use ack, when found (over grep). And will benefit from this drupal profile too.

This article was published on webschuur.com. And migrated to this blog.

in drupal214

About the author: Bèr Kessels is an experienced webdeveloper with a great passion for technology and Open Source. A golden combination to implement that technology in a good and efficient way. Follow @berkes on Twitter. Or read more about Bèr.

blog comments powered by Disqus