linux - bash 中的 dir 路径谜题?

标签 linux bash path find

在 bash 中使用时,/home/zzz/home/zzz/ 有什么区别?

我刚刚发现,当 /home/zzz 是另一个目录的链接时,find/home/zzz -type f 不会得到任何结果,但是 find/home/zzz/-type f 将返回该目录下的所有文件。我认为 bash 将 /home/zzz 视为链接类型文件,但在本例中 /home/zzz/ 视为目录。

还有其他区别吗?

最佳答案

大多数 Unix 实用程序(在本例中为 find)将尾部斜杠解释为“遵循符号链接(symbolic link)”。

来自POSIX Symbolic Link Specification :

When the final component of a pathname is a symbolic link, the standard requires that a trailing slash causes the link to be followed. This is the behavior of historical implementations. For example, for /a/b and /a/b/, if /a/b is a symbolic link to a directory, then /a/b refers to the symbolic link, and /a/b/ refers to the directory to which the symbolic link points.

另请参阅GNU Coreutils: Trailing slashes .

关于linux - bash 中的 dir 路径谜题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13469676/

相关文章:

linux - Bash脚本被杀死时如何杀死当前命令

sql - 使用 AWK 过滤掉每一行的不同字段

javascript - 在javascript中通过路径将值插入数组

c# - 带有空格的路径无法使用 File.CreateText(filePath) c# 创建文件

C++预处理器位置代码:: block ?

android - 如何从 ubuntu 获取 android 电池电量?

linux - 在 debian9 上从源 Rstudio Desktop 安装,错误 cmake

linux - 如何在 Linux 中安装 SSReflect 和 MathComp?

bash - 将 curl 响应的特定部分保存到变量

svg - 我可以沿 SVG 路径应用渐变吗?