Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question
up vote 5 down vote accepted

The simpler way would be:

rm -i httpd.conf?
share|improve this answer
thanks, it works :) – Termos Nov 22 '10 at 12:53

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:

share|improve this answer
This is super useful! Thanks. – gabe. Apr 1 '11 at 18:42

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.

share|improve this answer

Suppose you have two files in the same directory:httpd.conf and httpd.conf\r.

Copy the file(s) you want to keep:

$ sudo cp httpd.conf httpd-keep.conf

Simply remove ALL files that start with httpd.conf:

$ sudo rm httpd.conf*

Restore the original file:

$ sudo mv httpd-keep.conf httpd.conf

You need to BACKUP ALL OTHER FILES that start with "httpd.conf" if any before executing the rm command as shown above.

share|improve this answer

You can do:

rm $'httpd.conf\r'


rm 'httpd.conf^M'

You obtain ^M by pressing Ctrl-v then Ctrl-m.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.