Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I wrote a program that uses POSIX memory-mapping function (mmap)

The program takes a file (a.dat) and memory-maps it for reading/writing.

Due to errors in the program, every time I run the program a file with some weird names (e.g., ?d?P?^z??d?P?^z?) is created. The error is resolved but I am not able to delete the files.

I am not able to delete it either using command line or by select/deleting from window manager.

So how should i delete it? I'm using Ubuntu-11.04

share|improve this question

migrated from stackoverflow.com Jul 22 '12 at 1:01

This question came from our site for professional and enthusiast programmers.

    
Even if you cannot easily type the filename, deleting it from a graphical file manager should work fine. What error are you getting? –  Thomas Jul 15 '12 at 7:24
1  
@Aditya, I have no problem deleting such files from the command line when escaping their names with single quotes (rm '?d?P?^z??d?P?^z?'). Did you try that? –  Frédéric Hamidi Jul 15 '12 at 7:26
    
deleting from graphical window manager just says cannot delete file 'filename'. @Frédéric Hamidi Thanks for helping me delete one file. But the other one with name '?m?P???)?m?P???)' isnt getting deleted ... The error message says "rm: cannot remove `?m?P???)?m?P???)': No such file or directory" –  Aditya Kumar Jul 15 '12 at 7:31
1  
@Aditya, that other file must have non-printable characters in its name. Try the following steps: 1/ Move all the valid files out of that folder, 2/ Issue rm * inside the folder. –  Frédéric Hamidi Jul 15 '12 at 7:34
1  
When typing the file name try to start with quotes, then use auto completion as soon as it works (after one or two characters). Auto completion would be hitting the [tab] key to make the shell auto complete the name. This way you might be more successful to correctly escape the names. –  arkascha Jul 15 '12 at 7:34
show 2 more comments

2 Answers

up vote 9 down vote accepted

rm -i * will prompt you to delete each file. You can and should change '*' to a narrower match if there are a lot of files.

I've used that in the past and it works until you hit a special character or 2 that it does not like.

share|improve this answer
    
it worked. thanks –  Aditya Kumar Jul 15 '12 at 7:54
add comment

Another way is to remove the file by inode (see here)

share|improve this answer
    
Sounds like a good idea...thanks –  Aditya Kumar Jul 15 '12 at 12:51
add comment

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.