Assuming I want to change some filenames that end with jpg.jpg
to end only with .jpg
(in bash), and I want to do it by piping the output of find
to xargs
:
By using sed
:
find . -iname '*jpg.jpg' | xargs -I % mv -iv % $(echo % | sed 's/jpg.jpg/.jpg/g')
However, this does not replace jpg.jpg
with .jpg
in the destination file of mv
.
By using awk
:
find . -iname '*jpg.jpg' | xargs -I % mv -iv % $(echo % | awk '{gsub(/jpg.jpg/,".jpg")}; 1')
This neither does any replacement. Have I missed something?