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