You can do this with find and parameter substitution as follows:
#!/bin/bash find -name '*\\#015' | while IFS= read -rf do mv -- "${f}" "${f%?????}" done
- Put the above code in a script called
my_script.sh in /root/path/ and run it chmod +x my_script.sh && ./my_script.sh - Note that this will apply the changes recursively to all subfolders in
/root/path/ .
Explanation:
find -name '*\\#015' : find all files ending in \#015- Then for each file found:
mv "${f}" "${f%?????}" renames it from the old name to the new name with the last 5 characters in the deleted file name.
source share