What does // mean in a path?
/
is equivalent to //
From the POSIX specification (emphasis added):
3.267 Pathname
A string that is used to identify a file. In the context of POSIX.1-2008, a pathname may be limited to {PATH_MAX} bytes, including the terminating null byte. It has optional beginning
<slash>
characters, followed by zero or more filenames separated by<slash>
characters. A pathname can optionally contain one or more trailing<slash>
characters. Multiple successive<slash>
characters are considered to be the same as one<slash>
, except for the case of exactly two leading<slash>
characters.
And:
4.12 Pathname Resolution
...
A pathname consisting of a single<slash>
shall resolve to the root directory of the process. A null pathname shall not be successfully resolved. If a pathname begins with two successive<slash>
characters, the first component following the leading<slash>
characters may be interpreted in an implementation-defined manner, although more than two leading<slash>
characters shall be treated as a single<slash>
character.
For a nice discussion of exceptions (cygwin and directories) see: How does linux handle multiple consecutive path separators (/home////username///file)?
You can add multiple slashes to a directory and it will not change anything.
E.g. these three commands all do the same:cd /home
cd /home/
cd /home//
After any of these my current working directory is is set to /home (check with pwd
).
I guess that you have your prompt configured to do something smart and that you ran into unanticipated behaviour. What do you get when you echo $PS1
?
Link to a comment on https://unix.stackexchange.com/ which may explain it.