在 debian 和基于 debian 的测试:
$ cd // && pwd && ls
//
bin build dev home ...
Run Code Online (Sandbox Code Playgroud)
为什么路径//是有效路径?
小智 12
根据POSIX 规范:
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.
Run Code Online (Sandbox Code Playgroud)
我猜 bash 将两个斜杠解析为一个斜杠,因此它们的含义相同。并且根据规范,cd ///也应该给出相同的输出。
您可以使用以下命令检查当前目录的 inode 编号
stat -c "%i" .
你会注意到的inode编号/和//是相同的。