How can I recursively replace a string in all folders and files' name with a different string? I am running Red Hat 6 and I can find them with:
find . -name \*string\*
I've managed to do it for strings within files:
find . -type f -exec sed -i 's/string1/string2/g' {} +
but how could I replace in a similar way all file names?
rename
command? Is it perl rename? – terdon Jan 10 '18 at 09:35mv
is the final tool. You need to start withfind
+bash/shell
beforehand – RomanPerekhrest Jan 10 '18 at 09:35sed
) doesn't change any file names. It replaces the string inside the file but leaves the file name as it was. – terdon Jan 10 '18 at 09:37