delete ~ directory

Martin Stone martin.stone at db.com
Mon Apr 19 15:20:10 UTC 2004


That's right, Adam, "\~" is the way to go - I was just trying to get a warning 
out before anyone reading this actually went and tried "rm -rf -- ~" with 
disastrous consequences :-\

Of course, if you're in doubt about what you're referring to, you probably don't 
want to be using "-rf" ("rm -ri \~" would be safer) but I understand that it 
gets to be a habit :-)


Adam Voigt wrote:
> You need to do an escape, for example:
> 
> "vi ~"
> 
> Will tell you your trying to open a directory, and infact list the
> contents, but this:
> 
> "vi \~"
> 
> Will create a new file, called ~, so logically, you could use:
> 
> "rm -rf \~"
> 
> 
> 
> On Mon, 2004-04-19 at 11:09, Martin Stone wrote:
> 
>>Alexander Dalloz wrote:
>>
>>>Am Mo, den 19.04.2004 schrieb Vano Beridze um 09:17:
>>>
>>>
>>>
>>>>Hello
>>>>
>>>>I've accidentally (from a java program) created a directory named ~ in
>>>>my home directory.
>>>>Because ~ is a synonim for a home directory how can I delete this 
>>>>directory safely?
>>>>I mean I don't want to delete my whole home directory just that wierd
>>>
>>>one.
>>>
>>>
>>>>Thank you
>>>>Vano
>>>
>>>
>>>Besides the other suggestions, as a general annotation too, on bash you
>>>can use
>>>
>>>command -- special_sign_name
>>>
>>>The leading "--" tells the shell that the following is no options set.
>>>So in your case it would be while you are in the directory where the
>>>miscreated directory is placed
>>>
>>>rm -rf -- ~
>>>
>>>You can use this too if you accidentally created i.e. a file named "-f" 
>>>
>>>rm -f    will not work, but
>>>rm -- -f will do.
>>>
>>>Alexander
>>
>>No.  "rm -rf -- ~" absolutely WILL expand the ~ and remove your home directory! 
>>  The expansion of "~" is done by bash, not the rm command.  The -- only tells 
>>rm not to treat what follows as an option; it does not tell bash not to expand 
>>"~".  I would hope that you would test before posting such inaccurate and 
>>dangerous advice.






More information about the fedora-list mailing list