Sysop: | Amessyroom |
---|---|
Location: | Fayetteville, NC |
Users: | 43 |
Nodes: | 6 (0 / 6) |
Uptime: | 108:26:19 |
Calls: | 290 |
Files: | 905 |
Messages: | 76,683 |
Hi all,
a colleague (new to command line wizardry) seemed puzzled by the
existence of both globbing for file names (shell) and regular
expressions for strings (many other command line tools).
Since I am familiar with both mechanisms for decades, I never thought
about this "redundancy", but now I think he has a point, even more so if
you are using the "dired" file manager in Emacs, which further blurs the distinction between mangling text and working on files.
Since regexes are (at quick glance) a superset of globs, why not
consistently use the former for both file names and strings? The
few additional keystrokes (.* instead of *) are IMHO easily compensated
for by the more powerful capabilities of regexes.
A little reading on Wikipedia showed that both came into popular usage
in the early 70s. So why was globbing not dropped and regexes used throughout? It seems that ksh93 supports "regex globbing". bash has
"extended globbing", but this seems a clumsy, bolted-on solution. Are
there shells out there which follow a regex-only approach (of this would
be non-POSIX)?
Happy for any further insights (technical or historical) shed on this
topic!
Hi all,
a colleague (new to command line wizardry) seemed puzzled by the
existence of both globbing for file names (shell) and regular
expressions for strings (many other command line tools).
Since I am familiar with both mechanisms for decades, I never thought
about this "redundancy", but now I think he has a point, even more so if
you are using the "dired" file manager in Emacs, which further blurs the distinction between mangling text and working on files.
Since regexes are (at quick glance) a superset of globs, why not
consistently use the former for both file names and strings? The
few additional keystrokes (.* instead of *) are IMHO easily compensated
for by the more powerful capabilities of regexes.
A little reading on Wikipedia showed that both came into popular usage
in the early 70s. So why was globbing not dropped and regexes used throughout? It seems that ksh93 supports "regex globbing". bash has
"extended globbing", but this seems a clumsy, bolted-on solution. Are
there shells out there which follow a regex-only approach (of this would
be non-POSIX)?
Happy for any further insights (technical or historical) shed on this
topic!
Hi all,
a colleague (new to command line wizardry) seemed puzzled by the
existence of both globbing for file names (shell) and regular
expressions for strings (many other command line tools).
Since regexes are (at quick glance) a superset of globs, why not
consistently use the former for both file names and strings? The
few additional keystrokes (.* instead of *) are IMHO easily compensated
for by the more powerful capabilities of regexes.
Since regexes are (at quick glance) a superset of globs, why not
consistently use the former for both file names and strings?
There's an IMO interesting Q&A about globs and regexps, including some history, at:
https://unix.stackexchange.com/questions/136353/history-of-bash-globbing
Somehow I expected Plan 9's shell, rc, to have a more consistent
approach, but it also features standard globbing pattern.