Skip to content
Advertisement

Linux or unix find: shortcut for matching partial name

What I usually type:

find . -name "*pattern*"

what I want to type (for example. mnemonic = “all”):

afind . -name "pattern"

or

find . -aname "pattern"

I was just thinking there could be a shortcut like in the style of find . -iname "blah" or rgrep instead of grep -r

Even though, like the grep example, it only saves a couple of characters, they are shifted characters not as easy to type, and it is a commonly used search, probably.

Advertisement

Answer

You’d have to roll your own. e.g.:

$ afind () { find "$1" -name "*$2*"; }

$ afind . partial  
./dir/apartialmatch

You can add the definition to your .profile or whatever so that it’s always available.

Advertisement