Shell globs: Difference between revisions

From Helpful
Jump to navigation Jump to search
m (Helpful moved page Globs to Shell globs over redirect)
mNo edit summary
Line 1: Line 1:
<!--
<!--
In programming, particularly around filesystems and shells, a [[shell glob]] is associated with expanding wildcards
: usually specifically {{inlinecode|?}} meaning ''one'' character of anything and {{inlinecode|*}} meaning ''any'' amount of characters of anything
:: ...anything except {{inlinecode|/}}, that is


see also fnmatch, which is a "does a single name match this glob", whereas glob() both walks your filesystem and returns ''all'' matching filenames
globs (sometimes ''shell globs, because they are mainly seen in command lines), is associated with certain kinds of 'match this pattern'.


(apparently fnmatch() is ''used'' in the glob() implementation)
...very simple ones, usually only:
: {{inlinecode|?}} meaning ''one'' character of anything, and
: {{inlinecode|*}} meaning ''any'' amount of characters of anything
:: ...anything except the directory separateor, {{inlinecode|/}} {{(or presumably {{inlinecode|\}} if imitated in windows)}}




Compare with [[regular expressions]]
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.
That said:
Some people, when confronted with a problem, think "I know, I'll use regular expressions."
Now they have two problems. [https://blog.codinghorror.com/regular-expressions-now-you-have-two-problems/]




-->
-->

Revision as of 14:56, 28 November 2023