2

I have created a directory named -


[root@server50 public_html]# mkdir -

[root@server50 public_html]# ls -al

drwxr-xr-x 2 root root 4096 2011-03-16 02:22 -


How can I enter the directory using 'cd' command.

EEAA
  • 109,363
  • 18
  • 175
  • 245

2 Answers2

10

You can prepend the current directory:

cd ./-
Dennis Williamson
  • 62,149
  • 16
  • 116
  • 151
0

Look up the man page for cd and you see that a command-line argument consisting of a single hyphen is treated as a $OLDPWD variable. To prevent this from happening, you simply need to replace the "single hyphen" with more information from its path: Some ways to do this are:

cd /full/path/to/-
cd ./-
cd ././-

Anything so that a single hyphen "-" by itself does not appear on the command line, otherwise it will be interpreted as the old-working-directory

Michael Martinez
  • 2,645
  • 3
  • 24
  • 35