简体   繁体   中英

What does the path "//" mean?

I just found the direcory // on my machine and now i am wondering what it means.

user@dev:~$ cd /
user@dev:/$ pwd
/
user@dev:/$ cd //
user@dev://$ pwd
//

It is obvously the root directory, but when and why do i use the double slash instead of the single slash?

Is it related to the escaped path strings which i use while programming? For example:

string path = "//home//user//foo.file"

I also tried it with zsh but it changes to the usual root directory / . So I think its bash specific.

This is part of the specification for 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.

So your shell is just following the specification and leaving // alone as it might be implementationally defined as something other than / .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM