Globbing Patterns
Globbing is sometimes used to refer to pattern matching based on wildcard characters. The noun “glob” is used to refer to a particular pattern, e.g. “use the glob
*.logto match all those log files”. Its notation is simpler than regular expressions, and without their expressive power.
Wildcard matching
?- A
?(not between brackets) matches any single character. *- A
*(not between brackets) matches any string, including the empty string. #- A line starts with
#serves as a comment. !- Prefix
!negates the pattern. {},{!}{a,b,c}matches any one of a, b or c.{!glob}matches anything that does not matchglob.[],[^][abc]matches any character in the set a, b or c.[^abc]matches any character not in the set a, b or c.[a-z]matches any character in the range a to z, inclusive (A leading or trailing dash will be interpreted literally)./- Pattern ends with a
/matches pathname. - For example,
Documentation/*.htmlmatchesDocumentation/git.htmlbut notDocumentation/ppc/ppc.htmlortools/perf/Documentation/perf.html. **- A leading
**/matches in all directories. E.g.**/foo/barmatches file or directorybaranywhere that is directly under directoryfoo. - A trailing
/**matches everything inside. E.g.abc/**matches all files inside directory “abc”, relative to the location /**/matches zero or more directories. E.g.a/**/bmatchesa/b,a/x/b,a/x/y/band so on.- Other consecutive asterisks are considered invalid.
References
man 5 gitignore- Grunt Globbing Patterns