Rename file with weird name on Samba mount
Summary of relevant comments:
Unix file systems allows any character in a file name apart from \0
(nul) and /
(forward slash). The fact that ls
shows question marks is only because it can't display some of the characters of the filename in the current locale (which is one of the reasons why you should avoid parsing the output of ls
).
However, with a Samba share, you apparently have more strict requirements on filenames than on a standard Unix filesystem.
Since the file had a name that was "illegal" on your intermediate Samba share, the file was inaccessible by its correct name on the machine mounting the share.
The mv
didn't work since the name returned from the Samba share for the expansion of the globbing pattern was not the actual name of the file on the hosting filesystem, only Samba's own mangled version of the name.
Your solution was to log into the server that actually hosted the file (on a filesystem with less restrictive naming rules than Samba) and change the name of the file there. This was the correct course of action.
See also the Unix&Linux chat about this question.