0

Under my home directory I see a directory named ~. I guess I must have accidentally copied my home directory somehow.

Anyway, it's eaten up all my space and I'd like to remove it but obviously just running rm -r ~ will delete the entire contents of my home directory.

Any idea how to delete that ~ directory without any damage?

dan
  • 6,048
  • 10
  • 57
  • 125

4 Answers4

2

Just add a \ before it: rm -rf \~.

NRitH
  • 13,441
  • 4
  • 41
  • 44
1

Escape it so the shell doesn't expand the tilde. Any of these will do:

rm -r '~'
rm -r \~
rm -r ~/'~'
rm -r ~/\~
John Kugelman
  • 349,597
  • 67
  • 533
  • 578
1

I would use rm -rf \~ The \ escape key should stop you from deleting you're home directory.

Am Elemara
  • 11
  • 3
1

You can try to make an ls | grep -v <other files> statement, which ignores all the other files, so that it only lists the file with that weird name.
Then you do:

rm $(ls | grep -v <other files>)

Obviously, you need to be careful first to test this thoroughly.

Dominique
  • 16,450
  • 15
  • 56
  • 112