Using ack (sometimes packaged as ack-grep) I know that I can find paths that contain a specific string by doing:ack -g somestring
But what if I only want files which have "somestring" in their filenames?
Ack is designed as a replacement for 99% of the uses of grep. Ack searches the named input FILEs (or standard input if no files are named, or the file name - is given) for lines containing a match to the given PATTERN . By default, ack prints the matching lines.
Ack is a search tool like just grep, but it's optimized for searching in source code trees. Ack does almost all that grep does, but it differs in the following ways. Ack was designed to: Search directories recursively by default. Easily exclude certain file types or only search for certain file types.
I agree find is the way to go, but you could also easily do it with ack:
ack -f | ack "string"
Here, "ack -f" recursively lists all the files it would search; pipe that to the second ack command to search through that. ack -f does have the advantage of skipping over binaries and directories even without any more arguments; often, then a "find" command could be replaced by a much shorter "ack" command.
You can use find
utility. Something like this:
find /path/to/look/in -name '*somestring*' -print
On some systems, if you omit the path, current directory is used. On other systems you can't omit it, just use .
for current directory instead.
Also, read man find
for many other options.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With