Starting with bash: -lt and -gt arguments

It's short for less than and greater than. It's used for integer comparison in bash. You can read more by typing man test:

   ....
   INTEGER1 -gt INTEGER2
          INTEGER1 is greater than INTEGER2
   ....
   INTEGER1 -lt INTEGER2
          INTEGER1 is less than INTEGER2
   ....

You can find the definition of -lt and -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).

-lt and -gt are numeric comparisons (less-than [and not equal], greater-than [and not equal]). There are also less/greater-or-equal operators -le and -ge, and equal and not-equal operators -eq and -ne. These are numeric operators, so there will be an error if either side isn't a number, and 9 is considered less than 10.

The reason names like -lt are used rather than the usual < is that the character < would be interpreted as a redirection. The operators = and != 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 < and > 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.


They are just operators.

Simply: gt and lt mean > (greater than) and < (less than).

You can look here for more information on operators:

Tags:

Shell

Bash

Test