Removing file with strange characters in filename in OS X
Posted
by
SiggyF
on Super User
See other posts from Super User
or by SiggyF
Published on 2010-08-04T20:50:29Z
Indexed on
2011/01/11
12:55 UTC
Read the original article
Hit count: 203
After a memory error in my program, I am stuck with a file with a strange filename. It's proving quite resistant to all normal methods to remove files with strange names.
The filename is:
%8BUȅ҉%95d%F8%FF%FF\x0f%8E%8F%FD%FF%FF%8B%B5T%F8%FF%FF%8B%85\%F8%FF%FF\x03%85x%F8%FF%FF%8B%95D%F8%FF%FF%8B%BD%9C%F8%FF%FF%8D\x04%86%8B%B5@%F8%FF%FF%89%85%90%F8%FF%FF%8B%85X%F8%FF%FF\x03%85%9C%F8%FF%FF%C1%E7\x02%8B%8Dx
I tried the following:
- rm * -> "No such file or directory"
- rm -- filename -> "No such file or directory"
- rm "filename" -> "No such file or directory"
- ls -i to get the inode number -> "No such file or directory"
- stat filename -> "No such file or directory"
- zip the directory where the file is in -> error occured while adding "" to the archive.
- delete directory in finder -> error -43
- in python: os.unlink(os.listdir(u'.')[0]) -> OSError No such file or directory
- find . -type f -exec rm {} \; -> "No such file or directory"
- checked for locks on the file with lsof -> no locks
All these attempts result in a file (long filename here) not found error, or error -43. Even the ls -i.
I couldn't find anymore options, so before reformatting or repairing my filesystem (fsck might help) I thought maybe there is something I missed.
I wrote this small c program to get the inode:
#include <stdio.h>
#include <stddef.h>
#include <sys/types.h>
int main(void)
{
DIR *dp;
struct dirent *ep;
dp = opendir ("./");
if (dp != NULL)
{
while (ep = readdir (dp)) {
printf("d_ino=%ld, ", (unsigned long) ep->d_ino);
printf("d_name=%s.\n", ep->d_name);
}
(void) closedir (dp);
}
else
perror ("Couldn't open the directory");
return 0;
}
That works. I now have the inode, but the normal find -inum inode -exec rm '{}' \;
doesn't work. I think I have to use the clri now.
© Super User or respective owner