I have started using ack which is much faster than grep. However using ack I want to search for file name rather than file contents. Is there a way to do that?
Asked
Active
Viewed 1.1k times
4 Answers
17
Use the right tool for the right job. If you want to search for filename, use 'find':
$ # search for all *.txt file in current directory
$ find . -iname "*.txt"
Lie Ryan
- 4,517
- 3
- 25
- 27
9
I agree it makes sense to use find if you're just searching for *.txt files. However, ack has powerful file-type detectiong features, so you can use
ack -f --perl
which will find all the Perl files, based on both the filename (*.pm, *.pl, *.t and *.pod) and the shebang line.
Andy Lester
- 1,302
- 7
- 15