I've been a fool.
I've written a python script that's supposed to create a folder at ~/photos
and then write some files to it. However, instead of this it created a folder in my working directory called '~'
. (including the '
s).
I foolishly stormed ahead with an rm -rf ~
and hit enter before thinking. After spending the last few hours recovering I've ran the python script again and once again I'm faced with a folder named '~'
.
Too terrified to run any command to remove it, I've come here to ask: How do I delete this folder safely? Am I safe to run rm -r '~'
? (with the '
s)
ls '~'
beforerm -r '~'
to double-check. – Wieland Oct 30 '21 at 20:19ls '~'
was the solution for me here. Thanks for this. – Danny Herbert Oct 30 '21 at 20:23ls
andrm
work the same way, I would have renamed~
usingmv ./~ baddir
(./~
should not be interpreted as the home directory) and then check if the bad directory has been renamed tobaddir
. In the worst case, your home directory is renamed tobaddir
. In the good case, you can safely do arm -r baddir
. – Martin Rosenau Oct 30 '21 at 20:34ls -d ~
– Chris Davies Oct 30 '21 at 20:42"'~'"
. Userm -i ???
to match all names with 3 chars and interactively choose y or n for each one.ls
will report names inside quotes if it thinks they contain suspect characters -- the name may really be just~
. Usefind . -name '~'
-- it should not treat it as HOME. – Paul_Pedant Oct 30 '21 at 20:51find
to list files, it has lot of search and exclude options (size date permissions etc) once only desired file is printed, add-delete
flag – alecxs Oct 30 '21 at 22:11