Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: How to delete .*.~undo-tree~ files?



The usual trick works - just replace the "foo" with an asterisk while leaving the rest alone, including the backslashes:

rm -f .*.\~undo-tree\~

As Andreas said, you can also write it like like this:

rm -f .*.'~undo-tree~'

Which ties back into those expectations from other languages that Marc mentioned. It's important to remember that, unlike in those languages, quotation marks are not token delimiters in the shell. They don't terminate the current shell word (what other languages would just call a "string"); you can go in and out of quotes, switch kinds of quotes, etc. as often as you like within a single word.

So .*.'~undo-tree~' is still just one string, even though only part of it is in quotation marks.  The part in quotes is not subject to glob expansion; the part not in quotes is.

FWIW, if you want to do the same thing but recursing into subdirectories, you can use the special recursive glob sequence  **, as in **/.*.'~undo-tree~'

On Wed, Jun 12, 2024 at 9:06 AM Denis Bitouzé <dbitouze@xxxxxxxxxx> wrote:
Le 12/06/24 à 14h25, Andreas Kähäri a écrit :

> ... because a quoted * does not glob anything.
>
>       rm -f .*.'~undo-tree~'

That did the trick, thanks!
--
Denis



--
Mark J. Reed <markjreed@xxxxxxxxx>


Messages sorted by: Reverse Date, Date, Thread, Author