How to remove files with special characters in Linux
Solution 1
To remove a file with dashes, slashes or other special characters, the easiest way is to access the file using its inode. To get the inode of a file, just do a ls -li. When you have that number, use find to delete the file using the following command:
find . -inum [inode] -exec rm -i {} \;
Solution 2
To remove a file whose name starts with a `-‘, for example `-foo', use one of these commands:
rm --- -foo
rm ./-foo
so,
$ rm --- -\,my\?\ funky.file\$name
Via Johnny chadda
I use emacs dired to work files that have unprintable characters in their names.
I was always wondering how to do it from the command prompt… The “easy” way was to use mc (midnight commander) to do it. Thank for the nice trick. 🙂