53

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.

Jens Erat
  • 18,485
  • 14
  • 68
  • 80
A. K.
  • 665

3 Answers3

69

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. The -- stops processing options, so a file named -d will be removed by rm successfully.

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

JimR
  • 788
27

you can use ls -li to show all files by their inode. Then run this command to remove the file:

find . -inum ${INODE_NUM} -delete

I added -maxdepth 1 to my find just to be safe:

find . -maxdepth 1 -inum ${INODE_NUM} -delete
0

Wouldn't a basic find/confirm files by pattern and rm work?

find . -maxdepth 1 -name "*P*d*P*z" -exec ls -a {} \; 
find . -maxdepth 1 -name "*P*d*P*z" -exec rm {} \;
kisna
  • 109