I can't for the life of me figure out how find
with the test -name
works.
I run find / -name *in
and returns a bunch of results:
/sbin
/sbin/sulogin
/dev/stdin
to name a few.
It's as if it performed filename expansion, but that happens before the shell runs the command, so that can't be it. Also because I don't have any files in the current directory that match *in
. Plus, single quoting *in
yields the same results, which further supports that this can't be filename expansion.
The documentation leads me to believe that find
with -name
uses regular expressions, but the regex pattern *in
doesn't match the results I showed above.
Can someone enlighten me?
*in
pattern against the files from the cwd, it matches it against the the files from the directories it's walking through.-regex pattern
which is used to match the whole path (including slashes), while-name pattern
operates on the filename and uses shell patterns.