ack

Ack: Search directory tree for files with a particular extension


I basically just want to do ack foo *.citrus and have ack drill down and find the string 'foo' in all Citrus files in the current directory and below. The trouble is that this won't work if there aren't any Citrus files in the current directory.

I tried messing with -G without success. Do I really need to add a file type in .ackrc just to limit the search to files with a given extension?


Solution

  • By default, ack searches only in files with known types ( like *.java, *.cpp etc. ). It doesn't know about files *.citrus, so to search in such files you must use -a cmd line switch:

    $ack -a -G '\.citrus$' foo
    1.d/1.citrus
    1:foo_bar