Ack

What is ack?

ack is a wonderful replacement for grep.

How can we install ack if we want to use it inside Git Bash?

mkdir ~/bin
curl https://beyondgrep.com/ack-2.22-single-file > ~/bin/ack && chmod 0755 ~/bin/ack

How can we cause ack to print the name of the files that match our search pattern?

Use the -l switch:

ack -l

See https://serverfault.com/questions/57321/how-do-i-show-filenames-only-after-a-keyword-grep-search

My .ackrc file:

--type-add=php=.tpl
--ignore-dir=external
#make sure ack knows how to search common filetypes used in rails projects
--type-add=css=scss
--type-add=ruby=.haml,.rselm,.feature,.ru,.lock
--type-set=coffeescript=.coffee
--type-set=coffee=.coffee

#make sure ack knows how to search common filetypes used in node.js projects
--ignore-dir=node_modules
--type-set=coffee=.coffee
--type-set=jade=.jade
--type-set=feature=.feature
--type-set=json=.json

Can we have per directory or per project .ackrc file?

Yes. We can have per directory or per project .ackrc by putting:

export ACKRC=".ackrc"

into your .bashrc or .bash_profile file.

How can we ignore the .ackrc file?

If we want to ignore the .ackrc file with the —noenv option:

ack --noenv pattern

http://beyondgrep.com/documentation/

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License