Deleting files with strange names

Sometimes files are created with strange characters in the filename. The Unix file system will allow any character as part of a filename except for a null (ASCII 000) or a “/”. Every other character is allowed.

Hackers can create files with characters that make it difficult to see the directory or file. They can create the directory “.. ” with a space at the end, or create a file that has a backspace in the name, using

touch `printf "aa\bb"`

Now what what happens when you use the “ls” command:

$ ls
aa?b
$ ls | grep 'a'
ab

Note that when “ls” sends the result to a terminal, it places a “?” in the filename to show an unprintable character.

You can get rid of this file by using “rm -i *” and it will prompt you before it deletes each file. But you can also use “find” to remove the file, once you know the inode number.

$ ls -i
435304 aa?b
$ find . -inum 435304 -delete