In Bash I can write the following test
[[ "f" > "a" ]]
which results in returning 0, i.e. true. How does bash actually perform this string comparison? From my understanding >
does an integer comparison. Does it try to compare the ASCII value of the operands?
From
help test
:Internally, bash either uses
strcoll()
orstrcmp()
for that:The latter actually compares ASCII codes, the former (used when locale is enabled) performs a more specific comparison which is suitable for sorting in given locale.