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.

I was working in the bash terminal on my system (OSX 10.8.3 / bash version 3.2.48(1)-release (x86_64-apple-darwin12)) and I accidentally typed "cd //" instead of "cd /" to get back to the root directory.

Strange thing was that it took me to "//" which when I listed looked exactly like "/".

So my questions are: Is there any semantic difference betweens these two paths?
What if anything is the purpose of these two paths? and/or is it a bug?

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

In Unix and derivatives, multiple slashes following each other carry the same meaning as one slash. OS X is certified Unix, and thus follows that specification.

From the Single Unix Specification about the path name:

[A path] has an optional beginning slash, followed by zero or more filenames separated by slashes. A pathname may optionally contain one or more trailing slashes. Multiple successive slashes are considered to be the same as one slash.

The only special case is a path beginning with //. Its interpretation is up to the implementation (see Pathname Resolution in the SUS):

A pathname that begins with two successive slashes may be interpreted in an implementation-defined manner, although more than two leading slashes shall be treated as a single slash.

share|improve this answer
1  
NOTE: the most seen place where // is special is cygwin, where it is the analog of the \\filer\volume\ UNC path. –  Rich Homolka Apr 17 '13 at 21:22
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.