什么是路径//它与/

问题描述:

有什么区别我们知道根目录是/,根据posix,还有另一个不同于/的目录。当你ls /和ls //时,输出与stat相同,但是如果你是cd /和cd //,它们是不同的,尽管目录内容是相同的。 这让我很困惑。任何人都有答案?什么是路径//它与/

+0

你能提供说,他们是不同的参考?另外,你是什么意思,如果你“cd /”与“cd //”他们是不同的 - 你怎么知道? –

+0

@MarkkuK。对不起,我没有说清楚,这意味着pwd没有改变。正如devnull所说。你可以尝试一下。 – dspjm

+0

此外,如果您输入“cd // usr”(例如)而不是“cd/usr”,则最终输入“/ usr”,bash表示您不是“// usr”而pwd是“// usr” “太... – Tom

Bash FAQ

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'. 
+0

在我的git bash模拟(技术上是一台Windows机器)尝试'ls -l //'导致机器尝试读取并列出整个可用网络......哇。 –