Brace Expansions in Bash (and Fish) For Renaming Files

I’ve been using Linux and Bash for upwards of 18 years and for some reason it’s never occured to me to use brace expansions when renaming files until I saw this answer on AskUbuntu on disabling NotifyOSD.

So basically, just like when you’re globbing for e.g. images with:

ls *.{jpg,png,gif}

you can of course use the same kind of expansion when renaming files:

mv /some/old/file{,.backup}

which expands to:

mv /some/old/file /some/old/file.backup

And you can use it the other way around as well:

mv /some/old/file{.backup,}

which of course causes the removal of “.backup” from the file name.

Works in at least Bash and Fish. I haven’t tested other shells.