我错误地输入了一个命令 cd//
而不是 cd/
,而不是像我期望的那样得到错误,shell (Bash) 显示了提示好像我在//
目录:-
<username>@<hostname>://$
<username>@<hostname>://$ pwd
//
列出目录的内容,说明与/
相同。
那么cd//
到底是做什么的,和cd/
有什么区别呢?
最佳答案
其实没什么意思,被忽略了。
来自 Bash FAQ E10: :
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'.
还有 Unix standards状态:
A pathname that begins with two successive slashes may be interpreted in an implementation-defined manner, although more than two leading slashes shall be treated as a single slash.
关于linux - 双斜杠//in `cd//` 在 Linux 中是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20690828/