-h FILE (conditional operator)

true if the file is a symbolic link. false if the file does not exist or is not a symbolic link.

-L is an alias of -h.

Examples

Different ways to test if a file is a symbolic link:
1
2
3
4
test -h /bin/sh && echo "symbolic link"
[ -h /bin/sh ] && echo "symbolic link"
# Bash
[[ -h /bin/sh ]] && echo "symbolic link"
BashSupport Pro 是一个 支持 -h 的 Bash 集成开发工具 – 马上试用
© 2020–2024 Joachim Ansorg
声明
隐私政策
许可条款