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 ist eine Bash IDE mit Unterstützung für -eqprobieren Sie es aus!
© 2020–2024 Joachim Ansorg
Impressum
Datenschutz
Rechtliches