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:
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.
You can do:
or
You obtain
^M
by pressing Ctrl-v then Ctrl-m.Suppose you have two files in the same directory:
httpd.conf
andhttpd.conf\r
.Copy the file(s) you want to keep:
Simply remove ALL files that start with httpd.conf:
Restore the original file:
You need to BACKUP ALL OTHER FILES that start with "httpd.conf" if any before executing the
rm
command as shown above.