Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I use Ubuntu 9.10 (Karmic) and I have a directory with many files, among them these two files:

./baer.jpg
./bär.jpg

I would like to delete bär.jpg but I can't.

If I type rm b and hit TAB, it shows me both files, if I append ä and hit TAB, nothing gets displayed.

What must be done in order to delete bär.jpg?

Deleting the parent folder is not a solution for me, as there are plenty of files in this directory that are used by a productive environment.

share|improve this question
    
Try using midnight commander. I think you can install it with sudo apt get install mc. After that, run it with mc and us it to delete your file. –  Milan Todorovic Dec 27 '12 at 8:31
    
Thanks, but I was looking for a command-line solution. –  bzero Dec 27 '12 at 8:36
    
I thought so, that's why I put this in comments :) –  Milan Todorovic Dec 27 '12 at 8:41
1  
Techmically you could rename baer.jpg, remove bar.jpg and rename baer.jpg back ;-) –  Rinzwind Mar 20 at 9:04
    
midnight commander is command line. Do you mean coreutils? –  Sparhawk Mar 26 at 13:09

3 Answers 3

up vote 5 down vote accepted

I just found out how to delete such files witch special characters:

  1. cd <directory with that file>
  2. ls -ali
  3. At the very left of the directory listing you see the ID of the inode of each file.
  4. Delete your file via inode ID:

    find . -inum <inode ID of your file> -exec rm -i {} \;

This worked fine for my issue. Hope this helps!

share|improve this answer
    
+1. Very nice, if a bit convoluted. Note that -execdir is preferred (see man find). Also, another alternative would be to just run it with -delete instead, although this doesn't give you the warning of the -i flag. –  Sparhawk May 28 at 5:11

You could use bash wildcards with

 rm b?r.jpg

where ? stands for exactly one character. An alternative (if both file names were the same length) would be

rm b[!e]r.jpg

where [!e] means any character except "e".

share|improve this answer

Well, you can try using matching via grep to delete the file if it's a single problematic file.

neal@dsadsa:~$ touch junk_ä_deleteme
neal@dsadsa:~$ ls | grep junk | grep deleteme | xargs rm

Here, I am creating a file named junk_ä_deleteme. I delete it afterward by matching characters before ("junk") and after ("deleteme") the funny symbol. This approach isn't very good, but if it is a single file, it might work.

Perhaps a better solution would be to form a regex to match your file, and then pipe that filename to rm.

share|improve this answer
    
Piping ls to grep can be unintuitive. Probably easier to just use something like find . -name 'junk*deleteme' -delete –  Sparhawk May 28 at 5:14

Your Answer

 
discard

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.