Removing a Strange File by its I-number
If wildcards don't work () to remove a file with a strange name, try getting the file's i-number (). Then use find's -inum operator () to remove the file.
Here's a directory with a weird filename. ls (with its default -q option () on BSD UNIX) shows that it has three unusual characters in it. Running ls -i shows each file's i-number. The strange file has i-number 6239. Give the i-number to find and the file is gone:
%ls
adir afile b???file bfile cfile dfile %ls -i
6253 adir 6239 b???file 6249 cfile 9291 afile 6248 bfile 9245 dfile %find . -inum 6239 -exec rm {} \;
%ls
adir afile bfile cfile dfile
Instead of deleting the file, I could also have renamed it to newname with the command:
%find . -inum 6239 -exec mv {} newname \;
If the current directory has large subdirectories, you'll probably want to add the find -prune operator () for speed.
- JP