我们知道根目录是/,根据posix,还有另一个目录//不同于/。当你 ls/和 ls//时,输出是相同的,所以 stat,但是如果你 cd/和 cd//,它们是不同的,尽管目录内容是相同的。 这真的让我很困惑。有人得到答案了吗?
最佳答案
来自 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'.
关于linux - 什么是路径//,它与/有何不同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16840916/