linux - 双斜杠//in `cd//` 在 Linux 中是什么意思?

我错误地输入了一个命令 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/

相关文章:

linux - 使用命令或 bash 脚本清理环境?

linux - 解释导出 LANG、LC_CTYPE 和 LC_ALL 的效果

python - 如何关闭被杀死的程序打开的套接字?

linux - 从 rpm 包中提取规范文件

linux - tr 命令 - 如何将字符串 "\n"替换为实际的换行符 (\n)

c - 关于 putenv() 和 setenv() 的问题

linux - 除了使用 Ctrl + C 之外,如何在 linux 中停止正在运行的 R 命令?

linux - 进程可以拥有的每个不同 UID 的目的是什么?

c - bzero() & bcopy() 与 memset() & memcpy()

linux - cron 如何在内部安排作业?