bug-findutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Filename Expansion: Find Utility Pattern Matching vs Bash Shell Pattern


From: Michael Convey
Subject: Filename Expansion: Find Utility Pattern Matching vs Bash Shell Pattern Matching
Date: Tue, 16 Jun 2015 12:02:33 -0700

For filename expansion, the 'find' utility's '-name' option seems to
function similarly, but not exactly the same as the bash shell's builtin
pattern matching.

Here are the relevant sections of the GNU reference manual:

   - Bash shell pattern matching:
   http://www.gnu.org/software/bash/manual/bashref.html#Pattern-Matching
   - 'find' utility pattern matching:
   
http://www.gnu.org/software/findutils/manual/html_mono/find.html#Shell-Pattern-Matching

This is very confusing on its own. To add to this confusion, section 2.1.4
of 'find' utility's man page (referenced above) is entitled "Shell Pattern
Matching", which implies that 'find' is using the shell's builtin pattern
matching functionality. However, this does not appear to be the case
because according to the 'find' man page (http://goo.gl/ngQTKx), under
'-name pattern', it says the following:

"The filename matching is performed with the use of the fnmatch(3) library
function. Don't forget to enclose the pattern in quotes in order to protect
it from expansion by the shell."

>From this, it sounds like it is not the shell that is performing the
pattern matching, but the find utility using the fnmatch library.

Here are my questions:

   1. Is the bash shell's default filename expansion and pattern matching
   (extglob shell option disabled) different from that of the find utility
   using the -name option?
   2. If so, what are those differences?
   3. Does bash also use the fnmatch library or some other mechanism for
   filename expansion and pattern matching?


reply via email to

[Prev in Thread] Current Thread [Next in Thread]