Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I was trying to test out this buggy/new tool to see how it works, and it prompted me to choose a directory to use for stuff I am doing. From the directory ~/Code/indep, I typed in ~/Code/indep/tarbell. (Stupid, I could have just typed 'tarbell', but whatever.) It prompted me to create it because it didn't exist, I said yes. When I inspected the contents of this directory, here is what I see:

brian@navis:~/Code/indep$ ls
~ project1 project2 project3 ...

I thought "oh, weird, it created a symlink to ~". However:

brian@navis:~/Code/indep$ file ./~
./~: directory

file thinks it's a directory.

brian@navis:~/Code/indep$ ls -l
drwxr-xr-x 3 brian brian 4096 Nov  8 16:50 ~
drwxr-xr-x 8 brian brian 4096 Oct 14 18:42 project1
drwxr-xr-x 3 brian brian 4096 Sep 10 21:15 project2
drwxr-xr-x 5 brian brian 4096 Oct 14 19:33 project3
...

And so does ls -l.

I thought, "oh, ... is it a hard link? I've never really used those." But I tried to reproduce, and it's impossible to create a hard link to a directory. So... I guess I've narrowed this down to things I don't understand. Did I mount my home directory in this other directory somehow?

My main goal at this point is to remove the reference to my home directory in this folder (rm doesn't seem like the answer), but I'm also curious to know what's going on.

EDIT:

In retrospect, I understand exactly what happened. As was answered below, the program created a directory called "~" inside my current directory. The only really obfuscating fact about this is that I wasn't consistent with how I was actually viewing what the directory was. Sometimes I referred to it as "~" and sometimes as "./~". It's only if you do the latter that you can actually see what's going on, but until I understood this, I was conflating what I was seeing from using the absolute path of "~" to to what was in fact a local directory.

share|improve this question

1 Answer 1

up vote 7 down vote accepted

It's a directory whose name is "~". Your shell will attempt to expand "~" if it's the first character of an argument, so you have to take special measures.

$ mkdir ./~
$ file ./~
./~: directory
$ rm -ri ./~
rm: remove directory ‘./~’? y
share|improve this answer
    
I should be much more patient. –  Bepetersn Nov 8 '13 at 23:32
    
I didn't read through your proposed way of deleting the directory, and removed my home directory as soon as I read the first line and saw that you were right. –  Bepetersn Nov 8 '13 at 23:33

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.