Deleting the Impossible

It finally happened – a customer managed to give a pair of files some impossible names:


\*\*somefile_&name.mov
\*another_file.mov

(how they accomplished this is anyone’s guess) and then complained that they couldn’t delete or rename them. Which is true — the mv, rm, stat, and file commands all complained that they couldn’t stat the files, no matter how I quoted their names. Remembered reading once that you could nuke such files via inode, but had never had cause to try it. Sure enough: “ls -il” gives you the inode number in the filesystem. You can then use:

find . -inum [inode_number] -exec rm -i {} \;

There’s always a side door.

Music: Otis Redding :: Security

13 Replies to “Deleting the Impossible”

  1. I created and then was able to delete said files by escaping all special characters

    touch \\\*\\\*somefile_\&name.mov
    touch \\\*another_file.mov
    rm \\\*\\\*somefile_\&name.mov
    rm \\\*another_file.mov

  2. Dylan – You have absolutely *nothing* to fear on that count :)

    “Wait… I just wanted you to transfer my site to Birdhouse… I didn’t know you would need FTP access to my old site to do that. What is FTP? Where would I find this out? Change DNS settings at my registrar? Stop speaking Martian to me. Just transfer my site to Birdhouse.”

    Oi.

  3. I would just have opened up Nautilus… which can mount an ssh connection as if it’s a regular filesystem. Presto, blammo.

  4. Chris, if I understand you correctly, that would be same as e.g. having an SFTP or DAV session open on it. Then it would be up to the SFTP or DAV client in use as to whether it’s smart enough to handle weirdly named files. So the question is can Nautilus would be such a client… I just test with Transmit, Fugu, and the Finder to see how they handle a case like this. Give Nautilus that test and let us know how it does.

  5. I’d test that in Nautilus for you, but I am, through years of Unix indoctrination, programmed to be incapable of giving files names like that.

    Yeesh, that’s ugly.

  6. Well, Transmit *is* capable of deleting such a file. Wouldn’t have expected that – though the wildcards would have tripped it up. Funny that I didn’t think to try that to begin with, since that’s my normal access method – SFTP (ssh) connection via Transmit. Well, at least to my own stuff. I don’t allow direct root login on Birdhouse, so I don’t have write access to customer stuff via Transmit, so couldn’t have done it without knowing their credentials.

  7. You could chown -R the entire offending directory to your uid (negating the need to chown individually poorly named files), and then used Transmit to delete once you own the offenders. Then chown back.

Leave a Reply

Your email address will not be published.