| Deutsch English Français Italiano |
|
<v7ikrh$1kif$1@jmertens.eternal-september.org> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!news.misty.com!2.eu.feeder.erje.net!feeder.erje.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!jmertens.eternal-september.org!.POSTED!not-for-mail
From: Joerg Mertens <joerg-mertens@t-online.de>
Newsgroups: comp.unix.shell
Subject: Re: Globbing versus regular expressions
Date: Sun, 21 Jul 2024 11:36:47 +0200
Organization: A noiseless patient Spider
Lines: 36
Message-ID: <v7ikrh$1kif$1@jmertens.eternal-september.org>
References: <87wmlf2pq9.fsf@axel-reichert.de>
Injection-Date: Sun, 21 Jul 2024 11:36:50 +0200 (CEST)
Injection-Info: jmertens.eternal-september.org; posting-host="76b8cbc80dfd68666bfe477069cf88d8";
logging-data="53851"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18OwpmJHFtZIprWke0UAQiH8pzRID1V3XA="
User-Agent: tin/2.6.2-20221225 ("Pittyvaich") (OpenBSD/7.5 (amd64)) tinews.pl/1.1.61
Cancel-Lock: sha1:jtkJWhAaFlYQGahOAcx7R14dmAs=
Bytes: 2823
Axel Reichert <mail@axel-reichert.de> wrote:
> 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!
I guess, glob style matching is just easier to learn, especially
for non-technical persons. In regular expressions you have more
special characters you cannot use unescaped, like e.g. the dot,
which is part of many filenames. This makes it more inconvenient
to use in the context of file handling and it also takes more time
to learn all the details. I know both systems and I also tend to
use globbing when working with files, even if regex is available.
Most of the time you don't need the more complex possibilities regex
provides.