Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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.

share|improve this question

2 Answers 2

You can prepend the current directory:

cd ./-
share|improve this answer
    
Its working. Thank you very much –  Ajo Augustine Mar 15 '11 at 21:28
    
@ Ajo Augustine: if it is working you should consider accepting the answer by clicking the hollow checkmark. –  JeffG Mar 16 '11 at 20:19

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

share|improve this answer

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.