How to delete a tilde (~) folder?

In theory yes. In practice usually also yes. If you're calling a shell script or alias that does something weird, then maybe no.

You could use echo to see what a particular command would be expanded to by the shell:

$ echo rm -R ~
rm -R /home/frostschutz
$ echo rm -R "~"
rm -R ~

Note that echo removes the "" so you should not copy-paste what it prints. It just shows that if you give "~", the command literally sees ~ and not the expanded /home/frostschutz path.

If you have any doubt about any command, how about starting out with something that is less lethal if it should go wrong? In your case you could start out with renaming instead of deleting it outright.

$ mv "~" delete-me
$ ls delete-me
# if everything is in order
$ rm -R delete-me

For confusing file names that normally shouldn't even exist (such as ~ and other names starting with ~ or , or containing newlines, etc.), it's better to be safe than sorry.

Also consider using tab completion (type ls ~<TAB><TAB><TAB>), most shells try their best to take care of you, this also helps avoid mistyping regular filenames.


As Kalvin Lee mentioned, you can cd to the directory and remove its contents, then use rmdir to remove the directory. I recommend this over the rm -R approach because you're less likely to fat-finger the command and blow away your home directory.

Generally, you can put things that you don't want the shell to expand in single quotes. This will remove an empty directory named ~:

rmdir '~'

In addition to frostschutz's double quotes method, and Andy's simple quote one, there are also the shorter:

rm -r \~

and the relative path one:

rm -rf ./~