find: Full Name Patterns
1
1 2.1.2 Full Name Patterns
1 ------------------------
1
1 -- Test: -path pattern
1 -- Test: -wholename pattern
1 True if the entire file name, starting with the command line
1 argument under which the file was found, matches shell pattern
1 PATTERN. To ignore a whole directory tree, use '-prune' rather
1 than checking every file in the tree (⇒Directories). The
1 "entire file name" as used by 'find' starts with the starting-point
1 specified on the command line, and is not converted to an absolute
1 pathname, so for example 'cd /; find tmp -wholename /tmp' will
1 never match anything.
1
1 Find compares the '-path' argument with the concatenation of a
1 directory name and the base name of the file it's considering.
1 Since the concatenation will never end with a slash, '-path'
1 arguments ending in '/' will match nothing (except perhaps a start
1 point specified on the command line).
1
1 The name '-wholename' is GNU-specific, but '-path' is more
1 portable; it is supported by HP-UX 'find' and is part of the POSIX
1 2008 standard.
1
1 -- Test: -ipath pattern
1 -- Test: -iwholename pattern
1 These tests are like '-wholename' and '-path', but the match is
1 case-insensitive.
1
1 In the context of the tests '-path', '-wholename', '-ipath' and
1 '-wholename', a "full path" is the name of all the directories traversed
1 from 'find''s start point to the file being tested, followed by the base
1 name of the file itself. These paths are often not absolute paths; for
1 example
1
1 $ cd /tmp
1 $ mkdir -p foo/bar/baz
1 $ find foo -path foo/bar -print
1 foo/bar
1 $ find foo -path /tmp/foo/bar -print
1 $ find /tmp/foo -path /tmp/foo/bar -print
1 /tmp/foo/bar
1
1 Notice that the second 'find' command prints nothing, even though
1 '/tmp/foo/bar' exists and was examined by 'find'.
1
1 Unlike file name expansion on the command line, a '*' in the pattern
1 will match both '/' and leading dots in file names:
1
1 $ find . -path '*f'
1 ./quux/bar/baz/f
1 $ find . -path '*/*config'
1 ./quux/bar/baz/.config
1
1 -- Test: -regex expr
1 -- Test: -iregex expr
1 True if the entire file name matches regular expression EXPR. This
1 is a match on the whole path, not a search. For example, to match
1 a file named './fubar3', you can use the regular expression
11 '.*bar.' or '.*b.*3', but not 'f.*r3'. ⇒Syntax of Regular
Expressions (emacs)Regexps, for a description of the syntax of
1 regular expressions. For '-iregex', the match is case-insensitive.
1
1 As for '-path', the candidate file name never ends with a slash, so
1 regular expressions which only match something that ends in slash
1 will always fail.
1
1 There are several varieties of regular expressions; by default this
1 test uses POSIX basic regular expressions, but this can be changed
1 with the option '-regextype'.
1
1 -- Option: -regextype name
1 This option controls the variety of regular expression syntax
1 understood by the '-regex' and '-iregex' tests. This option is
1 positional; that is, it only affects regular expressions which
1 occur later in the command line. If this option is not given, GNU
1 Emacs regular expressions are assumed. Currently-implemented types
1 are
1
1 'emacs'
1 Regular expressions compatible with GNU Emacs; this is also
1 the default behaviour if this option is not used.
1 'posix-awk'
1 Regular expressions compatible with the POSIX awk command (not
1 GNU awk)
1 'posix-basic'
1 POSIX Basic Regular Expressions.
1 'posix-egrep'
1 Regular expressions compatible with the POSIX egrep command
1 'posix-extended'
1 POSIX Extended Regular Expressions
1
1 ⇒Regular Expressions for more information on the regular
1 expression dialects understood by GNU findutils.
1