Print this page
3768 fnmatch(5) is worded poorly
   1 FNMATCH(5)            Standards, Environments, and Macros           FNMATCH(5)
   2 
   3 
   4 
   5 NAME
   6        fnmatch - file name pattern matching
   7 
   8 DESCRIPTION
   9        The pattern matching notation described below  is used to specify
  10        patterns for matching strings in the shell. Historically, pattern
  11        matching notation is related to, but slightly different from, the
  12        regular expression notation. For this reason, the description of the
  13        rules for this pattern matching notation is based on the description of
  14        regular expression notation described on the regex(5) manual page.
  15 
  16    Patterns Matching a Single Character
  17        The following patterns matching a single character match a single
  18        character: ordinary characters, special pattern characters and pattern
  19        bracket expressions. The pattern bracket expression will also match a
  20        single collating element.
  21 
  22 
  23        An ordinary character is a pattern that matches itself. It can be any
  24        character in the supported character set except for NUL, those special
  25        shell characters that require quoting, and the following three special
  26        pattern characters. Matching is based on the bit pattern used for
  27        encoding the character, not on the graphic representation of the
  28        character. If any character (ordinary, shell special, or pattern
  29        special) is quoted, that pattern will match the character itself. The
  30        shell special characters always require quoting.
  31 
  32 
  33        When unquoted and outside a bracket expression, the following three
  34        characters will have special meaning in the specification of patterns:
  35 
  36        ?
  37              A question-mark is a pattern that will match any character.
  38 
  39 
  40        *


 216 
 217                   /foo/bar/x*/bam
 218 
 219                   search permission is needed for directories / and foo,
 220                   search and read permissions are needed for directory bar,
 221                   and search permission is needed for each x* directory.
 222 
 223                   If the pattern matches any existing filenames or pathnames,
 224                   the pattern will be replaced with those filenames and
 225                   pathnames, sorted according to the collating sequence in
 226                   effect in the current locale. If the pattern contains an
 227                   invalid bracket expression or does not match any existing
 228                   filenames or pathnames, the pattern string is left
 229                   unchanged.
 230 
 231 SEE ALSO
 232        find(1), ksh(1), fnmatch(3C), regex(5)
 233 
 234 
 235 
 236                                 March 28, 1995                      FNMATCH(5)
   1 FNMATCH(5)            Standards, Environments, and Macros           FNMATCH(5)
   2 
   3 
   4 
   5 NAME
   6        fnmatch - file name pattern matching
   7 
   8 DESCRIPTION
   9        The pattern matching notation described below  is used to specify
  10        patterns for matching strings in the shell. Historically, pattern
  11        matching notation is related to, but slightly different from, the
  12        regular expression notation. For this reason, the description of the
  13        rules for this pattern matching notation is based on the description of
  14        regular expression notation described on the regex(5) manual page.
  15 
  16    Patterns Matching a Single Character
  17        The following patterns match a single character: ordinary characters,
  18        special pattern characters and pattern bracket expressions. The pattern
  19        bracket expression will also match a single collating element.

  20 
  21 
  22        An ordinary character is a pattern that matches itself. It can be any
  23        character in the supported character set except for NUL, those special
  24        shell characters that require quoting, and the following three special
  25        pattern characters. Matching is based on the bit pattern used for
  26        encoding the character, not on the graphic representation of the
  27        character. If any character (ordinary, shell special, or pattern
  28        special) is quoted, that pattern will match the character itself. The
  29        shell special characters always require quoting.
  30 
  31 
  32        When unquoted and outside a bracket expression, the following three
  33        characters will have special meaning in the specification of patterns:
  34 
  35        ?
  36              A question-mark is a pattern that will match any character.
  37 
  38 
  39        *


 215 
 216                   /foo/bar/x*/bam
 217 
 218                   search permission is needed for directories / and foo,
 219                   search and read permissions are needed for directory bar,
 220                   and search permission is needed for each x* directory.
 221 
 222                   If the pattern matches any existing filenames or pathnames,
 223                   the pattern will be replaced with those filenames and
 224                   pathnames, sorted according to the collating sequence in
 225                   effect in the current locale. If the pattern contains an
 226                   invalid bracket expression or does not match any existing
 227                   filenames or pathnames, the pattern string is left
 228                   unchanged.
 229 
 230 SEE ALSO
 231        find(1), ksh(1), fnmatch(3C), regex(5)
 232 
 233 
 234 
 235                                  June 14, 2015                      FNMATCH(5)