Views:
41,590
Votes: 3
Tag :
bash
Link:
🔍 See Original Answer on Stack Overflow ⧉ 🔗
URL:
https://stackoverflow.com/q/43727451
Title:
How to test strings for lexicographic less than or equal in Bash?
ID:
/2017/05/01/How-to-test-strings-for-lexicographic-less-than-or-equal-in-Bash_
Created:
May 1, 2017
Edited: June 22, 2017
Upload:
September 15, 2024
Layout: post
TOC:
false
Navigation: false
Copy to clipboard: false
You can flip the comparison and sign around and test negatively:
$ a="abc"
$ b="abc"
$ if ! [[ "$b" > "$a" ]] ; then echo "a <= b" ; fi
a <= b
If you want collating sequence of “A” then “a” then “B”… use:
shopt -s nocaseglob