-1

just want to share an interesting or rather accidentally discovered bug for Unix 'rm' command. I have accidentally created the file named '--help'. However, when I try to delete using rm command, it does not work and it shows up the help menu for rm instead. Same to mv command, I want to rename it to a valid filename, it shows the help menu of mv.


[Answer] To delete the file named '--help', try to use 'find' command.

Thanks for your reading and I hope it somewhat helps.

CheeHow
  • 161
  • 5

2 Answers2

1

Try rm -- --help, this will do the trick:

$ rm -fv -- --help
removed ‘--help’
Mugurel
  • 903
  • 1
  • 9
  • 17
1

You can delete the file by quoting the filename or by preceding special characters with a back-slash.

Both of these work.

rm './--help' 

rm ./\--help
ewatt
  • 111
  • 3