Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

On various linux machines you can

cd /

and

cd //

The shell will say the current directory is '/' or '//' after using the corresponding command.

So the question is: What is the difference between '/' and '//', and if the answer is 'no difference' then why is '//' shown differently than '/'

BTW

cd ///
cd ////
cd /////

All result in the shell saying the current directory is '/'

Heres an example session:

[user@host /]$ cd //
[user@host //]$ cd /
[user@host /]$ cd //
[user@host //]$ cd /
[user@host /]$
share|improve this question
2  
This appears to be a bash-specific anomaly. If you try cd // in csh or zsh and then pwd it will show just '/' –  Doug Harris Oct 14 '09 at 17:24
    
interesting - that sheds some light on it –  sylvanaar Oct 14 '09 at 17:29
1  
For comparison: cd //usr/bin gives "//usr/bin", but cd /usr//bin gives "/usr/bin" (in Bash). –  Dennis Williamson Oct 14 '09 at 18:40
add comment

2 Answers

up vote 13 down vote accepted

Let's ask the man himself (Chester Ramey):

E10) Why does 'cd //' leave $PWD as '//'?

POSIX.2, in its description of 'cd', says that three or more leading slashes may be replaced with a single slash when canonicalizing the current working directory.

This is, I presume, for historical compatibility. Certain versions of Unix, and early network file systems, used paths of the form //hostname/path to access 'path' on server 'hostname'.

share|improve this answer
    
Much better answer than the (already pretty good) one from John T. –  innaM Oct 14 '09 at 20:32
add comment

It isn't an actual directory, it's a problem specific with bash. It's referenced in The Linux Documentation Project.

share|improve this answer
4  
why hasn't anyone fixed it? or have they? –  sylvanaar Oct 14 '09 at 17:49
add comment

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.