Use test to determine whether integer $COUNT is greater than 10.
Which condition is appropriate?
-gt means integer greater-than; -ge includes the boundary value.
Detailed explanation
[ "$COUNT" = 10 ]Incorrect. = compares the value as a string.
Incorrect. = compares the value as a string.
[ "$COUNT" -lt 10 ]Incorrect. -lt tests whether COUNT is less than 10.
Incorrect. -lt tests whether COUNT is less than 10.
[ "$COUNT" -gt 10 ]Correct. -gt tests whether COUNT is greater than 10.
Correct. -gt tests whether COUNT is greater than 10.
[ "$COUNT" -ge 10 ]Incorrect. -ge also accepts exactly 10, which is not required here.
Incorrect. -ge also accepts exactly 10, which is not required here.
Try it yourself
An example you can run in a temporary verification environment.
COUNT=11; if [ "$COUNT" -gt 10 ]; then printf greater; fiExpected result
greaterKey points
- -gt means greater than
- -ge means greater than or equal
- Integer comparison
Notes
- Environment: POSIX互換test / GNU Bash 5.2
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Read the scope first
Check whether the command acts on the current shell, a new process, an existing process, or a file.
Verify the observable result
Use the supplied command and compare the output with the expected result.