help-bash
[Top][All Lists]
Advanced

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

Re: How Bash can delete wildcard with exceptions


From: Greg Wooledge
Subject: Re: How Bash can delete wildcard with exceptions
Date: Sat, 1 Jul 2023 07:57:09 -0400

On Sat, Jul 01, 2023 at 01:05:46PM +0200, alex xmb ratchev wrote:
> > tried:
> > $ shopt -s extglob globstar
> >
> > $ rm *.BAR !(FOO.BAR)
> >
> > not work, it wiped all! Help!

That's because *.BAR matches all of them, and then !(FOO.BAR) matches
all but one.  So you passed all but FOO.BAR twice, and FOO.BAR once.

> shopt -s extglob dotglob
> 
> rm !(FOO.BAR)

This is the correct answer.



reply via email to

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