Shell globs: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
mNo edit summary |
||
Line 8: | Line 8: | ||
: {{inlinecode|*}} meaning ''any'' amount of characters of anything | : {{inlinecode|*}} meaning ''any'' amount of characters of anything | ||
:: ...anything except the directory separateor, {{inlinecode|/}} {{(or presumably {{inlinecode|\}} if imitated in windows)}} | :: ...anything except the directory separateor, {{inlinecode|/}} {{(or presumably {{inlinecode|\}} if imitated in windows)}} | ||
: [chars] meaning any one of the characters in this set | |||
:: can also be used to match a literal ? or * | |||
: [!chars] meaning anything other than the characters in this set | |||
:: I've seen [^chars] manage the same, though this isn't ''quite'' standard [https://pubs.opengroup.org/onlinepubs/007904975/utilities/xcu_chap02.html#tag_02_13_01] | |||
Revision as of 15:01, 28 November 2023
Globs, is associated with certain kinds of 'match this pattern'.
- also called shell globs, because they are mainly seen in command lines
...very simple ones, usually only:
- ? meaning one character of anything, and
- * meaning any amount of characters of anything
- ...anything except the directory separateor, / {{(or presumably \ if imitated in windows)}}
- [chars] meaning any one of the characters in this set
- can also be used to match a literal ? or *
- [!chars] meaning anything other than the characters in this set
- I've seen [^chars] manage the same, though this isn't quite standard [1]
see also fnmatch(), which is a "does a single name match this glob"
whereas glob() both walks your filesystem and returns all matching filenames
- apparently fnmatch() is used in the glob() implementation
Compare with regular expressions, which are more powerful (but still single-string) ways of expressing patterns.