{
    "content": [
        {
            "type": "text",
            "text": "# GLOB(7) (man)\n\n**Summary:** glob - globbing pathnames\n\n## See Also\n\n- sh(1)\n- fnmatch(3)\n- glob(3)\n- locale(7)\n- regex(7)\n\n## Section Outline\n\n- **NAME** (2 lines)\n- **DESCRIPTION** (8 lines) — 6 subsections\n  - Wildcard matching (8 lines)\n  - Character classes (6 lines)\n  - Ranges (6 lines)\n  - Complementation (9 lines)\n  - Pathnames (8 lines)\n  - Empty lists (23 lines)\n- **NOTES** (1 lines) — 2 subsections\n  - Regular expressions (8 lines)\n  - Character classes and internationalization (33 lines)\n- **SEE ALSO** (2 lines)\n- **COLOPHON** (7 lines)\n\n## Full Content\n\n### NAME\n\nglob - globbing pathnames\n\n### DESCRIPTION\n\nLong  ago,  in  UNIX V6,  there  was a program /etc/glob that would expand wildcard patterns.\nSoon afterward this became a shell built-in.\n\nThese days there is also a library routine glob(3) that will perform this function for a user\nprogram.\n\nThe rules are as follows (POSIX.2, 3.13).\n\n#### Wildcard matching\n\nA  string  is a wildcard pattern if it contains one of the characters '?', '*' or '['.  Glob‐\nbing is the operation that expands a wildcard pattern into the list of pathnames matching the\npattern.  Matching is defined by:\n\nA '?' (not between brackets) matches any single character.\n\nA '*' (not between brackets) matches any string, including the empty string.\n\n#### Character classes\n\nAn expression \"[...]\" where the first character after the leading '[' is not an '!' matches a\nsingle character, namely any of the characters enclosed by the brackets.  The string enclosed\nby  the brackets cannot be empty; therefore ']' can be allowed between the brackets, provided\nthat it is the first character.  (Thus, \"[][!]\" matches the three  characters  '[',  ']'  and\n'!'.)\n\n#### Ranges\n\nThere  is  one  special  convention:  two characters separated by '-' denote a range.  (Thus,\n\"[A-Fa-f0-9]\" is equivalent to \"[ABCDEFabcdef0123456789]\".)  One may include '-' in its  lit‐\neral  meaning  by  making it the first or last character between the brackets.  (Thus, \"[]-]\"\nmatches just the two characters ']' and '-', and \"[--0]\" matches the  three  characters  '-',\n'.', '0', since '/' cannot be matched.)\n\n#### Complementation\n\nAn  expression  \"[!...]\" matches a single character, namely any character that is not matched\nby the expression obtained by removing the first '!' from it.  (Thus,  \"[!]a-]\"  matches  any\nsingle character except ']', 'a' and '-'.)\n\nOne  can remove the special meaning of '?', '*' and '[' by preceding them by a backslash, or,\nin case this is part of a shell command line, enclosing them  in  quotes.   Between  brackets\nthese  characters stand for themselves.  Thus, \"[[?*\\]\" matches the four characters '[', '?',\n'*' and '\\'.\n\n#### Pathnames\n\nGlobbing is applied on each of the components of a pathname separately.  A '/' in a  pathname\ncannot  be  matched by a '?' or '*' wildcard, or by a range like \"[.-0]\".  A range containing\nan explicit '/' character is syntactically incorrect.  (POSIX requires that syntactically in‐\ncorrect patterns are left unchanged.)\n\nIf a filename starts with a '.', this character must be matched explicitly.  (Thus, rm * will\nnot remove .profile, and tar c * will not archive all your files; tar c . is better.)\n\n#### Empty lists\n\nThe nice and simple rule given above: \"expand a wildcard pattern into the  list  of  matching\npathnames\"  was  the  original  UNIX definition.  It allowed one to have patterns that expand\ninto an empty list, as in\n\nxv -wait 0 *.gif *.jpg\n\nwhere perhaps no *.gif files are present (and this is not an error).  However, POSIX requires\nthat  a wildcard pattern is left unchanged when it is syntactically incorrect, or the list of\nmatching pathnames is empty.  With bash one can force the classical behavior using this  com‐\nmand:\n\nshopt -s nullglob\n\n(Similar problems occur elsewhere.  For example, where old scripts have\n\nrm `find . -name \"*~\"`\n\nnew scripts require\n\nrm -f nosuchfile `find . -name \"*~\"`\n\nto avoid error messages from rm called with an empty argument list.)\n\n### NOTES\n\n#### Regular expressions\n\nNote  that  wildcard  patterns  are not regular expressions, although they are a bit similar.\nFirst of all, they match filenames, rather than text, and secondly, the conventions  are  not\nthe same: for example, in a regular expression '*' means zero or more copies of the preceding\nthing.\n\nNow that regular expressions have bracket expressions where the negation is  indicated  by  a\n'^', POSIX has declared the effect of a wildcard pattern \"[^...]\" to be undefined.\n\n#### Character classes and internationalization\n\nOf  course  ranges  were  originally  meant  to  be  ASCII ranges, so that \"[ -%]\" stands for\n\"[ !\"#$%]\" and \"[a-z]\" stands for \"any lowercase letter\".  Some UNIX implementations general‐\nized  this  so  that a range X-Y stands for the set of characters with code between the codes\nfor X and for Y.  However, this requires the user to know the character coding in use on  the\nlocal  system, and moreover, is not convenient if the collating sequence for the local alpha‐\nbet differs from the ordering of the character codes.  Therefore, POSIX extended the  bracket\nnotation  greatly,  both  for wildcard patterns and for regular expressions.  In the above we\nsaw three types of items that can occur in a bracket expression:  namely  (i)  the  negation,\n(ii) explicit single characters, and (iii) ranges.  POSIX specifies ranges in an internation‐\nally more useful way and adds three more types:\n\n(iii) Ranges X-Y comprise all characters that fall between X and Y (inclusive) in the current\ncollating sequence as defined by the LCCOLLATE category in the current locale.\n\n(iv) Named character classes, like\n\n[:alnum:]  [:alpha:]  [:blank:]  [:cntrl:]\n[:digit:]  [:graph:]  [:lower:]  [:print:]\n[:punct:]  [:space:]  [:upper:]  [:xdigit:]\n\nso  that  one can say \"[[:lower:]]\" instead of \"[a-z]\", and have things work in Denmark, too,\nwhere there are three letters past 'z' in the alphabet.  These character classes are  defined\nby the LCCTYPE category in the current locale.\n\n(v) Collating symbols, like \"[.ch.]\" or \"[.a-acute.]\", where the string between \"[.\" and \".]\"\nis a collating element defined for the current locale.  Note that this may be a  multicharac‐\nter element.\n\n(vi)  Equivalence  class expressions, like \"[=a=]\", where the string between \"[=\" and \"=]\" is\nany collating element from its equivalence class, as defined for the current locale.  For ex‐\nample,  \"[[=a=]]\" might be equivalent to \"[aáaäâ]\", that is, to \"[a[.a-acute.][.a-grave.][.a-\numlaut.][.a-circumflex.]]\".\n\n### SEE ALSO\n\nsh(1), fnmatch(3), glob(3), locale(7), regex(7)\n\n### COLOPHON\n\nThis page is part of release 5.10 of the Linux  man-pages  project.   A  description  of  the\nproject,  information about reporting bugs, and the latest version of this page, can be found\nat https://www.kernel.org/doc/man-pages/.\n\n\n\nLinux                                        2020-08-13                                      GLOB(7)\n\n"
        }
    ],
    "structuredContent": {
        "command": "GLOB",
        "section": "7",
        "mode": "man",
        "summary": "glob - globbing pathnames",
        "synopsis": null,
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [
            {
                "name": "sh",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/sh/1/json"
            },
            {
                "name": "fnmatch",
                "section": "3",
                "url": "https://www.chedong.com/phpMan.php/man/fnmatch/3/json"
            },
            {
                "name": "glob",
                "section": "3",
                "url": "https://www.chedong.com/phpMan.php/man/glob/3/json"
            },
            {
                "name": "locale",
                "section": "7",
                "url": "https://www.chedong.com/phpMan.php/man/locale/7/json"
            },
            {
                "name": "regex",
                "section": "7",
                "url": "https://www.chedong.com/phpMan.php/man/regex/7/json"
            }
        ],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 8,
                "subsections": [
                    {
                        "name": "Wildcard matching",
                        "lines": 8
                    },
                    {
                        "name": "Character classes",
                        "lines": 6
                    },
                    {
                        "name": "Ranges",
                        "lines": 6
                    },
                    {
                        "name": "Complementation",
                        "lines": 9
                    },
                    {
                        "name": "Pathnames",
                        "lines": 8
                    },
                    {
                        "name": "Empty lists",
                        "lines": 23
                    }
                ]
            },
            {
                "name": "NOTES",
                "lines": 1,
                "subsections": [
                    {
                        "name": "Regular expressions",
                        "lines": 8
                    },
                    {
                        "name": "Character classes and internationalization",
                        "lines": 33
                    }
                ]
            },
            {
                "name": "SEE ALSO",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "COLOPHON",
                "lines": 7,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "glob - globbing pathnames\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "Long  ago,  in  UNIX V6,  there  was a program /etc/glob that would expand wildcard patterns.\nSoon afterward this became a shell built-in.\n\nThese days there is also a library routine glob(3) that will perform this function for a user\nprogram.\n\nThe rules are as follows (POSIX.2, 3.13).\n",
                "subsections": [
                    {
                        "name": "Wildcard matching",
                        "content": "A  string  is a wildcard pattern if it contains one of the characters '?', '*' or '['.  Glob‐\nbing is the operation that expands a wildcard pattern into the list of pathnames matching the\npattern.  Matching is defined by:\n\nA '?' (not between brackets) matches any single character.\n\nA '*' (not between brackets) matches any string, including the empty string.\n"
                    },
                    {
                        "name": "Character classes",
                        "content": "An expression \"[...]\" where the first character after the leading '[' is not an '!' matches a\nsingle character, namely any of the characters enclosed by the brackets.  The string enclosed\nby  the brackets cannot be empty; therefore ']' can be allowed between the brackets, provided\nthat it is the first character.  (Thus, \"[][!]\" matches the three  characters  '[',  ']'  and\n'!'.)\n"
                    },
                    {
                        "name": "Ranges",
                        "content": "There  is  one  special  convention:  two characters separated by '-' denote a range.  (Thus,\n\"[A-Fa-f0-9]\" is equivalent to \"[ABCDEFabcdef0123456789]\".)  One may include '-' in its  lit‐\neral  meaning  by  making it the first or last character between the brackets.  (Thus, \"[]-]\"\nmatches just the two characters ']' and '-', and \"[--0]\" matches the  three  characters  '-',\n'.', '0', since '/' cannot be matched.)\n"
                    },
                    {
                        "name": "Complementation",
                        "content": "An  expression  \"[!...]\" matches a single character, namely any character that is not matched\nby the expression obtained by removing the first '!' from it.  (Thus,  \"[!]a-]\"  matches  any\nsingle character except ']', 'a' and '-'.)\n\nOne  can remove the special meaning of '?', '*' and '[' by preceding them by a backslash, or,\nin case this is part of a shell command line, enclosing them  in  quotes.   Between  brackets\nthese  characters stand for themselves.  Thus, \"[[?*\\]\" matches the four characters '[', '?',\n'*' and '\\'.\n"
                    },
                    {
                        "name": "Pathnames",
                        "content": "Globbing is applied on each of the components of a pathname separately.  A '/' in a  pathname\ncannot  be  matched by a '?' or '*' wildcard, or by a range like \"[.-0]\".  A range containing\nan explicit '/' character is syntactically incorrect.  (POSIX requires that syntactically in‐\ncorrect patterns are left unchanged.)\n\nIf a filename starts with a '.', this character must be matched explicitly.  (Thus, rm * will\nnot remove .profile, and tar c * will not archive all your files; tar c . is better.)\n"
                    },
                    {
                        "name": "Empty lists",
                        "content": "The nice and simple rule given above: \"expand a wildcard pattern into the  list  of  matching\npathnames\"  was  the  original  UNIX definition.  It allowed one to have patterns that expand\ninto an empty list, as in\n\nxv -wait 0 *.gif *.jpg\n\nwhere perhaps no *.gif files are present (and this is not an error).  However, POSIX requires\nthat  a wildcard pattern is left unchanged when it is syntactically incorrect, or the list of\nmatching pathnames is empty.  With bash one can force the classical behavior using this  com‐\nmand:\n\nshopt -s nullglob\n\n(Similar problems occur elsewhere.  For example, where old scripts have\n\nrm `find . -name \"*~\"`\n\nnew scripts require\n\nrm -f nosuchfile `find . -name \"*~\"`\n\nto avoid error messages from rm called with an empty argument list.)\n"
                    }
                ]
            },
            "NOTES": {
                "content": "",
                "subsections": [
                    {
                        "name": "Regular expressions",
                        "content": "Note  that  wildcard  patterns  are not regular expressions, although they are a bit similar.\nFirst of all, they match filenames, rather than text, and secondly, the conventions  are  not\nthe same: for example, in a regular expression '*' means zero or more copies of the preceding\nthing.\n\nNow that regular expressions have bracket expressions where the negation is  indicated  by  a\n'^', POSIX has declared the effect of a wildcard pattern \"[^...]\" to be undefined.\n"
                    },
                    {
                        "name": "Character classes and internationalization",
                        "content": "Of  course  ranges  were  originally  meant  to  be  ASCII ranges, so that \"[ -%]\" stands for\n\"[ !\"#$%]\" and \"[a-z]\" stands for \"any lowercase letter\".  Some UNIX implementations general‐\nized  this  so  that a range X-Y stands for the set of characters with code between the codes\nfor X and for Y.  However, this requires the user to know the character coding in use on  the\nlocal  system, and moreover, is not convenient if the collating sequence for the local alpha‐\nbet differs from the ordering of the character codes.  Therefore, POSIX extended the  bracket\nnotation  greatly,  both  for wildcard patterns and for regular expressions.  In the above we\nsaw three types of items that can occur in a bracket expression:  namely  (i)  the  negation,\n(ii) explicit single characters, and (iii) ranges.  POSIX specifies ranges in an internation‐\nally more useful way and adds three more types:\n\n(iii) Ranges X-Y comprise all characters that fall between X and Y (inclusive) in the current\ncollating sequence as defined by the LCCOLLATE category in the current locale.\n\n(iv) Named character classes, like\n\n[:alnum:]  [:alpha:]  [:blank:]  [:cntrl:]\n[:digit:]  [:graph:]  [:lower:]  [:print:]\n[:punct:]  [:space:]  [:upper:]  [:xdigit:]\n\nso  that  one can say \"[[:lower:]]\" instead of \"[a-z]\", and have things work in Denmark, too,\nwhere there are three letters past 'z' in the alphabet.  These character classes are  defined\nby the LCCTYPE category in the current locale.\n\n(v) Collating symbols, like \"[.ch.]\" or \"[.a-acute.]\", where the string between \"[.\" and \".]\"\nis a collating element defined for the current locale.  Note that this may be a  multicharac‐\nter element.\n\n(vi)  Equivalence  class expressions, like \"[=a=]\", where the string between \"[=\" and \"=]\" is\nany collating element from its equivalence class, as defined for the current locale.  For ex‐\nample,  \"[[=a=]]\" might be equivalent to \"[aáaäâ]\", that is, to \"[a[.a-acute.][.a-grave.][.a-\numlaut.][.a-circumflex.]]\".\n"
                    }
                ]
            },
            "SEE ALSO": {
                "content": "sh(1), fnmatch(3), glob(3), locale(7), regex(7)\n",
                "subsections": []
            },
            "COLOPHON": {
                "content": "This page is part of release 5.10 of the Linux  man-pages  project.   A  description  of  the\nproject,  information about reporting bugs, and the latest version of this page, can be found\nat https://www.kernel.org/doc/man-pages/.\n\n\n\nLinux                                        2020-08-13                                      GLOB(7)",
                "subsections": []
            }
        }
    }
}