Next: , Previous: Base Name Patterns, Up: Name


2.1.2 Full Name Patterns

— Test: -path pattern
— Test: -wholename pattern

True if the entire file name, starting with the command line argument under which the file was found, matches shell pattern pattern. To ignore a whole directory tree, use ‘-prune’ rather than checking every file in the tree (see Directories). The “entire file name” as used by find starts with the starting-point specified on the command line, and is not converted to an absolute pathname, so for example cd /; find tmp -wholename /tmp will never match anything. The name ‘-wholename’ is GNU-specific, but ‘-path’ is more portable; it is supported by HP-UX find and will soon be part of POSIX.

— Test: -ipath pattern
— Test: -iwholename pattern

These tests are like ‘-wholename’ and ‘-path’, but the match is case-insensitive.

In the context of the tests ‘-path’, ‘-wholename’, ‘-ipath’ and ‘-wholename’, a “full path” is the name of all the directories traversed from find's start point to the file being tested, followed by the base name of the file itself. These paths are often not absolute paths; for example

     $ cd /tmp
     $ mkdir -p foo/bar/baz
     $ find foo -path foo/bar -print
     foo/bar
     $ find foo -path /tmp/foo/bar -print
     $ find /tmp/foo -path /tmp/foo/bar -print
     /tmp/foo/bar

Notice that the second find command prints nothing, even though /tmp/foo/bar exists and was examined by find.

Unlike file name expansion on the command line, a ‘*’ in the pattern will match both ‘/’ and leading dots in file names:

     $ find .  -path '*f'
     ./quux/bar/baz/f
     $ find .  -path '*/*config'
     ./quux/bar/baz/.config
— Test: -regex expr
— Test: -iregex expr

True if the entire file name matches regular expression expr. This is a match on the whole path, not a search. For example, to match a file named ./fubar3, you can use the regular expression ‘.*bar.’ or ‘.*b.*3’, but not ‘f.*r3’. See Syntax of Regular Expressions, for a description of the syntax of regular expressions. For ‘-iregex’, the match is case-insensitive. There are several varieties of regular expressions; by default this test uses POSIX basic regular expressions, but this can be changed with the option ‘-regextype’.

— Option: -regextype name

This option controls the variety of regular expression syntax understood by the ‘-regex’ and ‘-iregex’ tests. This option is positional; that is, it only affects regular expressions which occur later in the command line. If this option is not given, GNU Emacs regular expressions are assumed. Currently-implemented types are

emacs
Regular expressions compatible with GNU Emacs; this is also the default behaviour if this option is not used.
posix-awk
Regular expressions compatible with the POSIX awk command (not GNU awk)
posix-basic
POSIX Basic Regular Expressions.
posix-egrep
Regular expressions compatible with the POSIX egrep command
posix-extended
POSIX Extended Regular Expressions

Regular Expressions for more information on the regular expression dialects understood by GNU findutils.