3

I wrote a Perl script and fat-fingered the name of my output file inserting a space in the file name, so now I have my_file .txt I have tried the following with no success (and no errors reported):

rm ./my_file\ .txt
rm "./my_file .txt"
find . -inum 123 -exec rm -i {} \;

None of the above removes the file, nor do I receive an error, warning, etc. I own the file, the directory, and have the appropriate permissions. The filehandle is closed and lsof ./my_file\ .txt does not show the file in use elsewhere. My google fu has failed me, so thanks in advance for any help you can offer.

EDIT: output of stat:

$ stat my_file\ .txt
  File: `my_file .txt'
  Size: 4096            Blocks: 8          IO Block: 4096   regular file
Device: fd00h/64768d    Inode: 16613511    Links: 1
Access: (0777/-rwxrwxrwx)  Uid: ( 4939/ abc1111)   Gid: (  100/  ABware)
Access: 2013-07-02 09:27:32.000000000 -0500
Modify: 2013-07-02 10:57:21.000000000 -0500
Change: 2013-07-02 10:57:21.000000000 -0500
21
  • 1
    Can you post output of stat my_file\ .txt please? All three solutions should be applicable, not receiving an error is especially weird. Is it possible the file gets recreated in the background?
    – Squeezy
    Jul 2, 2013 at 18:04
  • Have you tried find . -inum 123 -delete or just find my_file*txt -delete or rm my_file?.txt? Anyway, all of the methods you tried should work, is the file perhaps recreated? Has the Perl program exited?
    – terdon
    Jul 2, 2013 at 18:08
  • 1
    Still, all solutions should have worked. More than curious what caused it to silently fail.
    – Squeezy
    Jul 2, 2013 at 18:24
  • 1
    @Squeezy I'd like to know too. I'm certainly not a *nix pro, nor is it my job to be. But I do like to know why things don't work as expected. Jul 2, 2013 at 18:27
  • 2
    @terdon I didn't even think of that. I just got back to work and checked it. It is not an alias, but type revealed that my system has been modified to point to a homegrown version of rm. When I use the path /bin/rm it works as expected. The mystery is finally solved! And it took less than 24 hours... good work team :-D Jul 3, 2013 at 12:11

1 Answer 1

4

The most surefire way to delete things with weird names is to use find's -delete action. For example

find . -inum 16613511 -delete 

or

find . my_file?.txt -delete 

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .