STRING1 < STRING2 (conditional operator)
true if string1 sorts before string2 lexicographically.
< is not included in POSIX.
Avoid it if you want to stay compatible with POSIX shells.
Integers are compared with -lt.
Bash
This operator uses the current locale for sorting within a [[ ... ]] construct.
Links
Examples
- Different ways to test if a string is sorted before another one:
1 2 3 4test "$input" < " " && echo "special char" [ "$input" < " " ] && echo "special char" # Bash [[ "$input" < " " ]] && echo "special char"
BashSupport Pro 是一个 支持 < 的 Bash 集成开发工具 – 马上试用!