help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: default/simple globbing


From: lacsaP Patatetom
Subject: Re: default/simple globbing
Date: Wed, 27 Nov 2024 14:46:31 +0100

Le mer. 27 nov. 2024 à 14:36, Tapani Tarvainen <bash@tapanitarvainen.fi> a
écrit :

> On Wed, Nov 27, 2024 at 12:55:47PM +0100, lacsaP Patatetom (
> patatetom@gmail.com) wrote:
>
> > hi,
> >
> > I try to display only part of the `/sys/bus/usb/devices/` folder with `ls
> > /sys/bus/usb/devices/*-*[!.:]*` or `ls /sys/bus/usb/devices/*-*[^.:]*`
> but
> > it doesn't subtract entries with a dot or colon in their name (only usb
> > entries are removed).
>
> You can't really subtract things with glob patterns. In your pattern
> the problem is that * matches dots and colons as well, so the impact
> of *[!.:]* is only that there has to be at least one character other
> than a dot or colon, but there may be any number of them as well.
>
> > if it's possible, what is the correct expression to use without having to
> > activate extended globbing ?
>
> I'm afraid there isn't any. If you can limit the set of desired names
> you may be able to get what you want with multiple patterns, e.g.,
>
> ls *-[0-9] *-[0-9][0-9]
>
> Otherwise you can of course do strange things with additional
> commands, variable expansion &c, which might be useful depending on
> your application. Just for display simply ls | grep -v '[:.]' might do.
>
> Is there a reason why you don't want to use extended globbing?
>
> --
> Tapani Tarvainen
>
>
I'm just trying to do it with default globbing, but on the other hand, I
prefer to combine tools in a substitution rather than activate a bash
feature : it must be a question of habits...


reply via email to

[Prev in Thread] Current Thread [Next in Thread]