什么是路径//,它和/有什么不同 [英] What is path //, how is it different from /
本文介绍了什么是路径//,它和/有什么不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们知道根目录是/,根据posix,还有一个不同于/的目录//.当你 ls/和 ls//时,输出是一样的,stat 也是一样,但是如果你 cd/和 cd//,它们是不同的,虽然目录内容是一样的.这真的让我很困惑.有人有答案吗?
We know root directory is /, and according to posix, there is another directory // which differs from /. When you ls / and ls //, the output is the same, so as stat, however if you cd / and cd //, they are different, though the directory content are the same. That really confused me. Anyone got an answer?
推荐答案
来自 Bash 常见问题:
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'.
这篇关于什么是路径//,它和/有什么不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文