Specifying a folder to search & Easily including a file extension

77 views
Skip to first unread message

TM

unread,
Mar 4, 2012, 12:44:40 PM3/4/12
to ack dev/users
First of all, awesome tool!

But there are two things that would make it even more awesome:

1) An option to specify the folder ack should search in (still
recursing into subfolders of course). Right now I need to cd to it
first or exclude all other folders (some are pretty bug so not
excluding them would slow things down) which is kind of annoying.

2) Less clumsy way to include files of a certain extension ack doesn't
know yet; ack --type-set=foo=.foo --foo is very ugly, why not
something like ack --files '*.foo'?

Andy Lester

unread,
Mar 4, 2012, 12:58:27 PM3/4/12
to ack-...@googlegroups.com
> 1) An option to specify the folder ack should search in (still
> recursing into subfolders of course). Right now I need to cd to it
> first or exclude all other folders (some are pretty bug so not
> excluding them would slow things down) which is kind of annoying.

You just specify the starting directory (or directories).

ack --hh function_name /usr/local/include /usr/include

> 2) Less clumsy way to include files of a certain extension ack doesn't
> know yet; ack --type-set=foo=.foo --foo is very ugly, why not
> something like ack --files '*.foo'?


ack function_name *.foo

You can specify filenames explicitly on the command line and ack will search them whether or not they're of types it knows.

xoxo,
Andy

--
Andy Lester => an...@petdance.com => www.petdance.com => AIM:petdance

Jeremy Simmons

unread,
Apr 19, 2012, 10:55:30 AM4/19/12
to ack-...@googlegroups.com
in response to including files of a certain extension -
when I try to search for files with an extension not defined by a type, the output of ack is:
 
>ack foo *.xaml
ack.pl: *.xaml: No such file or directory
 
what am I doing wrong?!
 
ack 1.96
Running under Perl 5.14.2 at G:\strawberry_perl\perl\bin\perl.exe

Andy Lester

unread,
Apr 19, 2012, 11:08:57 AM4/19/12
to ack-...@googlegroups.com

On Apr 19, 2012, at 9:55 AM, Jeremy Simmons wrote:

 
>ack foo *.xaml
ack.pl: *.xaml: No such file or directory
 
what am I doing wrong?!

In that example, you're asking the shell to expand "*.xaml" and give you a list of files to pass to ack.  That works if you're in the directory with the .xaml files, but apparenlty you're not.

So what you want to do is tell ack that .xaml is a filetype it should search.  Do this

ack --type-add=xaml=.xaml foo

and assuming you want to do that over and over, but the --type-add=xaml=.xaml in your ~/.ackrc file.  Then you can just do

ack foo

or 

ack --xaml foo
Reply all
Reply to author
Forward
0 new messages