removing hidden special characters from RHEL filenames


In a RHEL7 server we do receive files from different others laptops through outlook or direct attach, these files are stored in a CIFS driver configured with encoding iocharset=iso8859-1.

For some reasons and maybe due to an encoding issues the application don't recognize the invalid characters and replace them by ¿ but i the system level the same invalid character is replaced by ?, so I created a small script to rename filenames and replace the normal ? by ¿ :

find . -name "*[?]*" -exec bash -c 'x="{}"; y="$(sed "s/[?]\+/¿/g" <<< "$x")" && mv "$x" "$y" ' \;

The problem is recently I did notice that there is a hidden / added before ?, my command is not working anymore, the system is not seeing the / as well, to find it I need to press the tab button to locate the hidden /
Here is an example:

ls
Salvage?_Not_Released_?

I type mv Salvage and the press Tab to complete the filename, then /? appears

mv Salvage\?_Not_Released_\?

Do you have any idea on how to fix this issue?

728x90

0 Answers removing hidden special characters from RHEL filenames