conditional-operator

Bash > — lexicographic ordering

Checks whether the left string sorts after the right in the current locale. It is not a numeric comparison. In ordinary [ commands an unquoted > is parsed as output redirection; use [[ ]] for this Bash-specific syntax. Run the example independently in a fresh private directory. Expected output (one item per line): after=0; equal=1.

Formal Syntax & Structure

bash syntaxbash
[[ left > right ]]

Parameters & Attributes

NameTypeDescription
leftstringFirst string.
rightstringSecond string.

Return Value

exit status

0 for a true condition; 1 for a false condition. Invalid expressions may fail differently.

Working Example

Example Snippetbash
export LC_ALL=C[[ z > a ]]; printf 'after=%s\n' "$?"[[ a > a ]]; printf 'equal=%s\n' "$?"
Bash Reference