linux - 什么是路径//,它与/有何不同

标签 linux kernel posix pathname

我们知道根目录是/,根据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/

相关文章:

linux - Bash 中的“ls”命令 - 匹配数字

c - 如何编写信号处理程序来捕获 SIGSEGV?

c - 从内核到用户空间(DMA)

assembly - 磁盘 IO 操作在内核级程序集中通常如何看待?

path - 哪里可以找到 posix 路径规范?

c++ - 将单例实例限制为线程

c - C 中的线程如何工作?

linux - 限制核心文件大小

ruby - ruby gem 'gamebox' 的“捆绑”问题

linux - 在 Linux 内核中找不到方法 __kernel_vsyscall