I'm trying to delete a file with a weird name from within Terminal on a Mac.
It's a very old file (1992) with null characters in the name: ���Word Finder® Plus™�.
Have you tried the GUI dragging the file to the 'Trash' from within Finder, then clearing the Trash?
How about using single quotes instead of double?
How about mv '��Word Finder® Plus™' /tmp/testname in single quotes and let the system remove it during reboot.
Are all the relevant permissions set for YOU to read and write from and to the file?
Remember any of these could cause problems so be very aware.
And finally are you absolutely sure you have the FULL filename and not missing, say, trailing spaces(s)?
That is all I can think of so far...
FWIW, I would solve this by doing exactly what MadeInGermany suggests in post#3 (unless there are so many files in the directory that you would be there all day to do it).
Thanks so much for the prompt ideas. Unfortunately, none have succeeded. I've repeated tried to delete by dragging and always get "The operation can't be completed because an unexpected error occurred (error code -50)." The file is in a folder by itself that I've tried to delete the entire folder, but that won't work either.
Latest attempts:
Single quotes
12FX009:5 dpontius$ rm '��Word Finder® Plus™'
rm: ��Word Finder® Plus™: Invalid argument
rename with testname in tmp folder:
12FX009:5 dpontius$ mv '��Word Finder® Plus™' /tmp/testname
mv: rename ��Word Finder® Plus™ to /tmp/testname: Invalid argument
Permissions look fine:
12FX009:5 dpontius$ ls -l
total 48
-rwxr-xr-x@ 1 dpontius staff 0 Feb 27 1992 ��Word Finder® Plus™
Delete with wildcards:
12FX009:5 dpontius$ rm -i ./*Word*
remove ./��Word Finder® Plus™? y
rm: ./��Word Finder® Plus™: Invalid argument
Throughout, the little bugger is still there. No trailing spaces present. I find it interesting to see the unicode characters wisecracker revealed. Does anyone know how to use that information to identify a file to delete?
The output of ls -li on the zombie so we can see the file size, access rights and inode number.
What operating system is this?
What type of filesystem is this? eg, ZFS, UFS or what?
There are other nuclear options but you would need to do a full filesystem backup first, then keep users off until the job is done.
We are talking filesystem internals now.
Hmm, looking at the hexdump reminded me of something that happened in my AMIGA heydays...
Because you quoted that file dates back to 1992 maybe instead of each 'NUL' character being decoded as a UNICODE, they are a single byte ONLY.
I suspect that each 'NUL' is not 0xE2 0x90 0x80 but is in fact ONLY 0x00 with the top bit set giving 0x80 and they are being interpreted as UNICODE characters.
I have no idea if this would work but this might work in bash:
namestart=$'\x80\x80'
rm -rf "${namestart}"*
This could even apply to the (R) and TM characters as well.
Just a lateral thought.
I know that you say that you want to delete this "zombie" file but do you know how it got there? With a name like that including unprintable characters and possibly a set inode number I have a thought that it could be part of a license key for an age-old application. If you are still using that application you could find that it stops dead as soon as you succeed in deleting this file.
This file was on ancient backups that I copied years ago onto my now-spacious hard drive. I suspect that it (and a second file from 1998 I haven't mentioned yet called �SurfSim 1.0.0� Prefs�) were part of some copy protection scheme. I've used neither program for decades. So yes, the file was created on a very different operating system, whatever the Macintosh was running two decades ago.
debugfs with its unlink and rm commands comes to mind, but it might suffer from the same problems as the other tools. When using it, be very careful and know exactly what you are doing!