6

I've somehow managed to create a file with the name "--help". If I try to remove the file using "rm" funny stuff happens. Please help

here's a printout of the dir listing:

[pavel@localhost test]$ ls -la
total 3640
drwxrwxr-x.  5 pavel pavel    4096 Jun 19 18:33 .
drwxrwxr-x.  6 pavel pavel    4096 Jun  9 12:23 ..
-rw-rw-r--.  1 pavel pavel 1070592 Jun 12 09:40 --help
1
  • 3
    Humor bonus for "please help".
    – tripleee
    Jun 20, 2013 at 12:16

3 Answers 3

12

Either

rm ./--help

or

rm -- '--help'

See Utility Syntax Guideline 10 in the POSIX.1-2008 specification for a description of the end-of-options indicator, --

1
  • 3
    Prefer the first one, please. '--' will not be understood by some commands (and even some old versions of rm !) Jun 20, 2013 at 9:27
4
#!/usr/bin/env python

import os
os.unlink("--help")

Or you can do it interactively.

1
  • 3
    you could actually do it directly from command line: python -c "import os; os.unlink('--help')"
    – tutuDajuju
    Jun 20, 2013 at 7:30
4

Can you do...?:

ls -il
find . -inum [NUMBER] -exec rm -i {} \;

Super stolen from Squeezy.

1
  • 1
    That's overkill. Just use -- to set end-of-options.
    – ott--
    Jun 20, 2013 at 13:18

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