I have a folder on my Mac called "␀␀␀␀HFS+ Private Data". I'm trying to delete it but it contains a bunch of odd characters that are choking unlink, rm and mv, making it difficult to remove it and its contents. I've tried whipping up some code to call unlink() directly just in case unlink/rm/mv binaries are doing some other stuff - but no, unlink() can't parse this character.
I used echo and od to figure out what character this is:
************@Trinity:~/Desktop/test$ echo -e "␀" | od -t oC -An
342 220 200 012`
I looked up 342 here: http://ascii-code.com - and found that it's part of the Latin-1 set. I tried iconv to convert it to UTF-8:
************@Trinity:~/Desktop/test$ iconv -f latin1 -t utf-8 "␀␀␀␀HFS+ Private Data"
iconv: ␀␀␀␀HFS+ Private Data: I/O error
So how do I delete this folder? Can I pass hex/oct codes to rm or mv or something? I've tried everything I can think of, including rm *, invoking sudo, etc. The problem is that unlink chokes on that character, so I need to change that character somehow. I was also thinking about installing Debian in a VM and giving it access to this folder so that I could try from there, in case this is an issue with the tools I have in my OS X environment.
EDIT: I tried this:
************@Trinity:~/Desktop/test$ echo -e "␀␀␀HFS+ Private Data" | od -t oC -An
342 220 200 342 220 200 342 220 200 110 106 123 053 040 120 162
151 166 141 164 145 040 104 141 164 141 012`
************@Trinity:~/Desktop/test$ echo "\342\220\200\342\220\200\342\220\200\110\106\123\053\040\120\162\151\166\141\164\145\040\104\141\164\141\012" | xargs rm
rm: 342220200342220200342220200110106123053040120162151166141164145040104141164141012: No such file or directory
************@Trinity:~/Desktop/test$ echo "\342"
\342
EDIT2: showing the unlink() error
************@Trinity:~/Desktop/test$ unlink test3.txt
************@Trinity:~/Desktop/test$ unlink "␀␀␀␀HFS+ Private Data/1.txt"
unlink: ␀␀␀␀HFS+ Private Data/1.txt: Invalid argument
************@Trinity:~/Desktop/test$ cd "␀␀␀␀HFS+ Private Data/"
************@Trinity:~/Desktop/test/␀␀␀␀HFS+ Private Data$ unlink 1.txt
unlink: 1.txt: Invalid argument
EDIT3: showing that it's not an HFS+/filesystem issue, but rather a filename issue
************@Trinity:~/Desktop/test$ mkdir "␀␀␀␀testTest"
************@Trinity:~/Desktop/test$ rm -r "␀␀␀␀testTest"
rm: ␀␀␀␀testTest: Invalid argument
EDIT4: this might be progress... I'm going to mess with the locale next.
************@Trinity:~/Desktop/test$ ls | grep -i *test* | xxd
0000000: e290 80e2 9080 e290 80e2 9080 7465 7374 ............test
0000010: 5465 7374 0a Test.
************@Trinity:~/Desktop/test$ rm -r $'\xe2\x90\x80\xe2\x90\x80\xe2\x90\x80\xe2\x90\x80\x74\x65\x73\x74\x54\x65\x73\x74\x0a'
rm: ␀␀␀␀testTest
: No such file or directory
Follow-up to this: nope, false hope. I dropped the \x0a on the end and it 'worked'... kind of.
************@Trinity:~/Desktop/test$ rm -r $'\xe2\x90\x80\xe2\x90\x80\xe2\x90\x80\xe2\x90\x80\x74\x65\x73\x74\x54\x65\x73\x74'
rm: ␀␀␀␀testTest: Invalid argument