Both [[
and [
are built into bash
. [
is equivalent to the test
command, also a builtin. (Well, almost equivalent; [
requires a matching ]
, test
doesn't.)
According to the bash manual:
When used with test
or [
, the <
and >
operators sort
lexicographically using ASCII ordering.
(Bourne shell builtins are documented here).
But the expression in [[
... ]]
follows the rules of Bash conditional expressions:
When used with [[
, the <
and >
operators sort
lexicographically using the current locale. The test
command uses
ASCII ordering.
(There's another test
/ [
command provided as part of the GNU coreutils package, typically /usr/bin/test
. This command doesn't provide <
and >
operators, which are not specified by POSIX. The external command should be irrelevant if you're using bash, unless you explicitly give the full path /usr/bin/test
.)
Your question is tagged both "bash" and "sh". If you're using bash, you should probably use the bash-specific [[
feature rather than [
. If you want greater portability (e.g., if your script might be used with a shell other than bash), you can't rely on the [[
builtin, and you can't assume that [
or test
supports <
and >
.