In bash, why doesn’t this work:
$ echo $((1 -gt 2 ? 3 : 4))
bash: 1 -gt 2 ? 3 : 4: syntax error in expression (error token is "2 ? 3 : 4")
Neither does this:
$ echo $(((1 -gt 2) ? 3 : 4))
bash: (1 -gt 2) ? 3 : 4: missing `)' (error token is "2) ? 3 : 4")
Use:
Or:
The -gt family is used by the test command, while the operators allowed in $(()) are described here and here. You can’t mix and match.
Note from the standard that “only signed long integer arithmetic is required.” You need to use bc.