Accidentally created directory named "~" (tilde)
I managed to make a directory literally named ~
.
(Apparently, Python's os.mkdir('~/something')
does this.)
How do I remove it without nuking my home?
Also, if it helps, I have my real /home
on a separate partition. And the duplicate ~
is located in (the real ) ~
.
Escape the ~
with \~
or use single quotes '~'
.
so you can
rmdir ~/\~
or
cd ~ ; rmdir '~'
What python giveth, python taketh away:
$ python -c 'import os; os.makedirs("~/foo")'; tree; python -c 'import os; os.removedirs("~/foo")'; tree
.
└── ~
└── foo
2 directories, 0 files
.
0 directories, 0 files
If you did os.mkdir
, you could undo it with os.rmdir
(and similarly for os.makedirs
and os.removedirs
).