arg1 -eq arg2 (conditional operator)

true if integer arg1 has the same value as integer arg2.

Please note, that strings are compared by = or ==.

Examples

Different ways to test two integers for equality:
1
2
3
4
test "$n" -eq 42 && echo "the answer is $n"
[ "$n" -eq 42 ] && echo "the answer is $n"
# Bash
[[ "$n" -eq 42 ]] && echo "the answer is $n"
BashSupport Pro 是一个 支持 -eq 的 Bash 集成开发工具 – 马上试用
© 2020–2023 Joachim Ansorg
声明
隐私政策
许可条款