How to delete file containing special characters in Linux?
I've created a linux bash file in a windows text editor. This file contained commands for moving files to another location under linux.
After i ran this file i discovered that destination files have "\r" symbol in their end. (I guess this is because linux and windows use different line end symbols)
So 'Dir' command shows that i have files like these: "httpd.conf\r" while 'ls' shows the same filename as: "httpd.conf?"
How do i delete these files ?
These commands do not work:
Rm httpd.conf\r
Rm httpd.conf\\r
rm 'httpd.conf\r'
I receive the following error:
rm: cannot lstat `httpd.confr': No such file or directory
The simpler way would be:
rm -i httpd.conf?
If you get a really chewy filename, you can delete it by inode:
run ls -il
to get the inode number, then use:
find -inum <inode number> -exec rm -i {} \;
to delete it.
(Credit to one of my old bookmarks for this one: http://www.cyberciti.biz/tips/delete-remove-files-with-inode-number.html)
If you are using bash and bash's tab completion is enabled you can use it to complete the filename with the character in question automatically escaped.