delete or rename a file with \r as the file name
Solution 1:
Us ls -li
to get the inode number for the file (first column), then use find
to delete it (assuming inode is 12345):
find . -inum 12345 -exec rm -i {} \;
Solution 2:
use ANSI-C quoting: rm $'\r'
http://www.gnu.org/software/bash/manual/bashref.html#ANSI_002dC-Quoting
Solution 3:
I would personally reach for Python:
>>> import os
>>> '\r' in os.listdir('.')
True
>>> os.unlink('\r')
But you can also do this from the shell if you understand escape characters.
$ ls -b $'\r'
\r
$ rm -vi $'\r'
rm: remove regular empty file ‘\r’? y
removed ‘\r’
Solution 4:
Another quick way to remove a file called <carriage return>
if you're using the Bash shell is:
$ rm <control-v><control-m>
Solution 5:
Single-character file names are unusual, and if you don't have any other such files in your directory, you can try this:
rm ?
I'm too lazy to learn or look up how to quote strange characters, so I've used variants of this a number of times when I was stuck with files with difficult names.