什么是路径//,它与/有何不同 [英] What is path //, how is it different from /

查看:229
本文介绍了什么是路径//,它与/有何不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆