I tried to cd into a directory named - that I created for experimenting. I could not from Bash. How do I cd into it?
With Nautilus on Ubuntu 13.10 I could easily do this, and even create files inside it effortlessly. I did a Google search and here is what I got. That covers the case when directories begin with a -, like -test, but not the case when the entire name is one single -. Even rm does not work, although I was able to delete it from Nautilus.
cat test.txt >- copies text from test.txt into a file named -, but cat - >test2.txt does what it would do in normal circumstances, that is, copy input from stdin into test2.txt, not from the file -.
Why does Nautilus have no problem with this but bash does?
cd -means cd to the last directory you were in. So don't name directories -; or ~, or /, or ., or .. – Dec 30 '13 at 04:13cd "-"to work, but it does not. – Dec 30 '13 at 04:14-as a directory name in thecdcommand is specified by POSIX to be equivalent to:cd "$OLDPWD" && pwd. So it does work, just not as you are expecting it to; it returns you to your last working directory. – Michael Burr Dec 30 '13 at 04:16cdcommand that assigns it a special meaning. – chepner Dec 30 '13 at 14:29