我正在尝试使用 -h filename
命令检查 KornShell (ksh) 脚本中是否存在符号链接(symbolic link)。这在 HP 盒子上效果很好。
不确定 Linux、AIX 和 Solaris 机器的正确选项是什么。
对此有什么见解吗?
最佳答案
-h
是 POSIX spec 的一部分;它应该在任何模糊合理的地方都有效。
根据 Mac OS X 上的man test
:
-h file True if file exists and is a symbolic link. This operator is retained for compatibility with previous versions of this program. Do not rely on its existence; use -L instead.
-L
也是标准化的,因此如果您发现 -h
不起作用,您应该尝试使用 -L
。
关于shell - 检查文件是否是 Linux 上的链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/706421/