Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

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.

1  
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
up vote 4 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
1  
Instead of \~ you can also say '~' (i.e., with single quotes). – bitmask Dec 14 '12 at 18:04
    
@bitmask: you are right – user1284631 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
1  
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
1  
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

 
discard

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