I'd like to specify the file name extensions when searching in a folder of files. Read the man page of ack and still confused. Why something like the following not working?
ack --type-add=xlog=.xlog "foobar"
Update
I use ack 2.14 under Perl 5.16.2.
First, I'm assuming you're using ack 2.x, because the filetype rules are very different in ack 2.x than 1.x.
Your --type-add=xlog=.xlog
told ack about the filetype "xlog", but you didn't do anything with it. Do you only want to search .xlog files? Then you need --xlog
. Are you trying to exclude .xlog files from your searching? If so, then you need to say --noxlog
.
So if you only want .xlog files, you do
ack --type-add=xlog=.xlog --xlog text-to-search-for
Now, that's a pain to type over and over again, so you can put
--type-add=xlog=.xlog
into an ackrc file (either /etc/ackrc or ~/.ackrc or somewhere in your project directory) and then you only need to do
ack --xlog text-to-search-for