You can find the definition of
-gt in the documentation of the
test command (
man test), or in the documentation of bash since
test is a built-in command in bash (like in most other shells).
-gt are numeric comparisons (less-than [and not equal], greater-than [and not equal]). There are also less/greater-or-equal operators
-ge, and equal and not-equal operators
-ne. These are numeric operators, so there will be an error if either side isn't a number, and
9 is considered less than
The reason names like
-lt are used rather than the usual
< is that the character
< would be interpreted as a redirection. The operators
!= also exist, but they perform a string comparison:
test 00 -eq 0 is true whereas
test 00 = 0 is false.
Some shells, including bash, also have operators
> which perform a string lexicographic comparison, so
test 9 \< 10 is false because
9 is sorted before
1 (the backslash prevents the character
< from being interpreted as a redirection operator). These shells also offer the double-bracket syntax for tests, e.g.
[[ 9 < 10 ]] (as opposed to
[ 9 \< 10 ]), which can't have redirections inside so the
< doesn't need to be quoted.