Thursday, May 2, 2024
26
rated 0 times [  26] [ 0]  / answers: 1 / hits: 21555  / 2 Years ago, tue, july 19, 2022, 3:37:43

I inadvertently created a file called -r in my home directory. Now I cannot get rid of it:



rm -rf
rm: missing operand
Try 'rm --help' for more information.


Other attempts:



rm /-/r
rm: cannot remove ‘/-/r’: No such file or directory


Another one:



rm -r
rm: missing operand
Try 'rm --help' for more information.


Is there a way to remove this file without deleting the whole directory?


More From » command-line

 Answers
1

In this case you have to use the double-dash (--) in your command arguments.



The purpose of it is to tell to the command that what's follow has not to be taken as an argument to the command but a simple input. In the case of rm, a file or directory name.



So type rm -- -r and you should get rid of this file.


[#24680] Wednesday, July 20, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
quivedge

Total Points: 223
Total Questions: 116
Total Answers: 124

Location: Slovenia
Member since Wed, Apr 6, 2022
2 Years ago
;