Removing stubborn files with backslashes and other special characters in Linux
We recently had to remove a file with a pretty odd file name: "\ я\ 005-2.jpg".
Normally, you can deal with oddities (such as spaces in file names) by just putting the file in quotes and removing normally like...
However, when it comes to backslashes and other special characters in file names, things get tricky.
The way to remove a file like the above is to first find the Inode number. You can do this in one of two ways:
First, using \ я\ 005-2.jpg as an example, you can run
stat from the command line.
A second option is to run
ls -li as in...
This will give you an output like this:
In either event, you can see that the Inode value is 13770830.
To get rid of the troublesome \ я\ 005-2.jpg (a.k.a. 13770830) use the
find command and tell it to remove by Inode as in
-exec rm -i. For example:
Farewell \ я\ 005-2.jpg, we hardly knew ya.