LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   can't remove file "-r" (https://www.linuxquestions.org/questions/linux-newbie-8/cant-remove-file-r-4175545031/)

dthims 06-10-2015 07:04 PM

can't remove file "-r"
 
have been trying to get rid of that file, its in the home directory. permission for that file is 644. tried rm -f "-r" did not work.

schneidz 06-10-2015 07:05 PM

Code:

rm ./-r

dthims 06-10-2015 07:09 PM

thnx for the quick reply. it worked

Sefyir 06-10-2015 10:26 PM

-- is used to say "there are no more options after this"
So while this means recursively remove filea
Code:

rm -r filea
This means remove the file -r and remove the file filea
Code:

rm -- -r filea

From man bash
Code:

      --        A -- signals the end of options and disables  further  option
                processing.  Any arguments after the -- are treated as file‐
                names and arguments.  An argument of - is equivalent to --.


goumba 06-10-2015 11:14 PM

Quote:

Originally Posted by Sefyir (Post 5375401)
-- is used to say "there are no more options after this"

It is useful to note that this applies to all of your base utilities - cp, mv, &c.


All times are GMT -5. The time now is 07:54 PM.