I'm using bash 5.0.7, and hope that I can expand the variable And="&&" and Or="||" in the double square brackets:
$ [[ 1 > 0 $And 1 < 0 ]] bash: syntax error in conditional expression bash: syntax error near `$And` $ [[ 1 > 0 ${And} 1 < 0 ]] bash: syntax error in conditional expression bash: syntax error near `${And}` I hope there's a way to do this because that will largely simplify one of my codes. And also, any explanations will be highly appreciated: I am really curious about how sh/bash works! Thank you very much in advance.
eval(which might involve quoting hell with the other parts of your test). Can you show what you're trying to achieve in the end? Perhaps there might be some other way to do what you want.[[ a > b ]]will do a lexicographical comparison on its operands:[[ 2 > 11 ]] && echo 2 is greater than 11(and to add insult to injury, they'll do it using the current locale ;-)).iforcasebased on$Andrather than trying to shoe-horn it into the[[command.start=100000; end=213000. The problem is whenendis over midnight, e.g.end=020000, I want$nowto be larger than$startOR smaller than$endinstead of AND. Is there another nonverbose way to do it?endbeforestart, add 24h toend. Ifnowbeforestart, add 24h tonow. Then compare.