-gt
means "greater than". It is used to compare integers for the inequality that is usually written >
in other languages (in some shells, with the test
utility or inside [ ... ]
, >
compares two strings for lexicographical ordering, so it has a very different meaning from -gt
).
-gt
is documented in the manual for test
or [
, or in your shell's manual if these are built-in utilities, as
n1 -gt n2
True if the integer n1
is algebraically greater than the integer n2
; otherwise, false.
(the above is taken from the POSIX standard text about the test
utility)
Fortran also uses this abbreviation in its .GT.
relational operator for numbers.
The other relevant operators for comparing integers in the shell with test
or in [ ... ]
are -ge
("greater-than or equal"), -lt
("less-than"), -le
("less-than or equal"), -eq
("equal") and -ne
("not equal").
Interestingly, all of these are the same in Fortran (.GT.
, .GE.
, .LT.
, .LE.
, .EQ.
and .NE.
).
-z
tests for string length zero, also called 'empty' or 'null', but not the string consisting of one character0
used to represent the integer zero. – dave_thompson_085 May 29 '18 at 16:41