Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm a beginner to using bash on OSX, and I somehow created a ~ dir in a project subfolder. (It appears as a directory, rather than a symlink.)

Is there a safe way to get rid of this ~ directory instance without bash expanding the tilde wiping my local user directory?

This is a really goofy question, but it would be a huge help to figure out how to deal with this.


I ended up using rm -rfi ./\~, which worked safely.

Thanks, everyone!

share|improve this question

migrated from stackoverflow.com Dec 15 '12 at 9:24

This question came from our site for professional and enthusiast programmers.

rm -r '~' should do. Or rm -r './~'. If you want to be really safe, run rm with the -i option (interactive) that will prompt you before erasing anything. E.g., rm -ri './~'. –  gniourf_gniourf Dec 14 '12 at 16:17

2 Answers 2

up vote 3 down vote accepted

Yes. Use:

rm -rf \~

(that is: tilda prefixed with a backslash)

But, to be really sure, place yourself in the parent directory of the tilda and type:

rm -rf ./\~

That way, you really specify: the tilde in the current directory

share|improve this answer
Instead of \~ you can also say '~' (i.e., with single quotes). –  bitmask Dec 14 '12 at 18:04
@bitmask: you are right –  axeoth Dec 14 '12 at 18:17

rmdir will only remove empty directories. That way you are really sure you won't lose anything important.

share|improve this answer
Unless you pass -r, so will rm. –  bitmask Dec 14 '12 at 18:33
rm will not remove a directory at all without -r, which makes it a bad choice for this task. –  Emil Vikström Dec 14 '12 at 18:47
I cannot help but noticing that I was talking utter nonsense before and that you are absolutely right. Sorry for that (the nonsense talking, not the noticing, that is). –  bitmask Dec 14 '12 at 20:37

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.