I was working on a project to control my digital camera using Ubuntu and gphoto2. At one point I noticed a new "~" directory in my project folder, /home/greg/project/~. When I enter this new "~" directory, it takes me backwards to my home directory /home/greg/ (as you might expect).

I don't know exactly how this happened, but my suspicion is that when I ran gphoto2 on the command line and specified an output file, I typed "~/filename.jpg" expecting the file would show up in my home directory, but instead bash put a new "~" directory in the working directory. I'm wasn't aware something like that could be done (if that's what happened).

More important than how it got there is how I should get rid of it. I can't remove the directory, because as far as I can tell it is my home directory. It doesn't appear to be a sym-link, (at least not according to ls -l), but I'm not sure what that would even really mean.

1 Answer
1

Same thing with rm, rmdir, etc. The shell changes ~ to /home/greg before passing it to the commands, unless you quote or escape it. You can see this with echo:

anthony@Zia:~$ echo ~
/home/anthony
anthony@Zia:~$ echo \~
~

You'll want to be careful, because rm -Rf ~ would be a disaster. I suggest if at all in doubt, first rename it (mv -i \~ newname) then you can examine newname to make sure you want to delete it, and then delete it.