I have A LOT of files named "bar_foo.txt" in a directory, and I'd like to rename them to "foo_bar.txt" instead.
In sed and vim the regex to to this would be something like 's/\(bar\)_\(foo\)/\2_\1/g', backreferencing the search in the replacement.
Is there a way to do this with
rename? I've seen some hacks pipinglstosedtobash, but that's obviously not an amazing way to do it.Are there another tools that does this?
Is there a name for the "sed and vim flavour" of regex?
$&(because$0is the program name). – Walf Jul 07 '22 at 03:32