filenamesack

Can ack find files based on filename only?


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?


Solution

  • 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.