是什么在`CD //双斜线//`在Linux中是什么意思? [英] What does double slash // in `cd //` mean in Linux?

查看:2528
本文介绍了是什么在`CD //双斜线//`在Linux中是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我输入一个命令 CD // 而不是 CD / 错误和而不是得到一个错误如我所期望的外壳(击)显示一个提示,如果我在 // 目录: -

I've entered a command cd // instead of cd / by mistake and instead of getting an error as I'd expect the shell (Bash) showed a prompt as if I'm in the // directory:-

<username>@<hostname>://$
<username>@<hostname>://$ pwd
//

列出该目录的内容表明,它是一样的 /

那么究竟是什么 CD // 做的,什么是从差 CD /

So what exactly cd // do and what's the difference from cd /?

推荐答案

其实没什么意思,将被忽略。

Actually it means nothing and is ignored.

猛砸常见问题E10:

E10)为什么CD //'假$ PWD为'//'?

E10) Why does 'cd //' leave $PWD as '//'?

POSIX.2,在其CD的说明中,表示三个或更多的领先
  斜线可以用单斜线canonicalizing的时被替换
  当前工作目录。

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.

这是我presume,由于历史的兼容性。某些版本
  Unix和早期的网络文件系统,形式使用的路径
  //主机名/路径来访问服务器的主机名'路径'。

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的标准规定:

这与两个连续斜线开头的路径可能是PTED间$ P $
  在实现定义的方式,虽然两个以上的领先
  斜线应被视为一个单一的斜杠。

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.

这篇关于是什么在`CD //双斜线//`在Linux中是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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