Remove files with odd name


Sometimes an user create a file or directory with a odd filename, for example:
server@root:/root # touch /tmp/test/^Easasasasa.txt

This “^E” is the result of a CTRL+E. With “ls”, we have the following:
server@root:/tmp/test # ls -ltr
total 0
-rw-r----- 1 root sys 0 Nov 30 15:34 asasasasa.txt

Note that you cannot see the ^E in filename, so the system will not recognize it as “asasasasa.txt”:
server@root:/tmp/test # rm asasasasa.txt
rm: asasasasa.txt non-existent

The solution is work with the file’s inode:
server@root:/tmp/test # ls -lia
total 96
11 -rw-r----- 1 root sys 0 Nov 30 15:34 asasasasa.txt
5 drwxr-x--- 2 root sys 96 Nov 30 15:34 .
2 drwxrwxrwt 8 root root 49152 Nov 30 15:33 ..

The number “11” is the inode of the odd file. Now we can remove it using the find command:
server@root:/tmp/test # find . -inum 11
./asasasasa.txt
server@root:/tmp/test # find . -inum 11 -exec rm -rf {} \;

, , ,