The Cookie Machine - Click here to drag window

DUMMY TEXT - Real text set in assets/js/theCookieMachine.js

If you can read me, I'm broken!

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
⇧ How to speed up 1/2 hour to sort 133 new entries in 2,700 entry Bash Array in RAM? Set HDMI sound output automatically on connect/disconnect  ⇩