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 /]$
link|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
feedback

2 Answers

up vote 12 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'.

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

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

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

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.