Hacker News new | ask | show | jobs
by barrkel 3881 days ago
Shorthand for $(( )) is $[ ]

In predicate contexts (which means return code in bash) like if, while or the left hand side of '&&', consider using (( )) - this has an exit code of 0 if the arithmetic expression is true (non-zero) and 1 otherwise. Use it like this:

    let x=3*3
    if (( x > 5 )); then
        echo greater than five
    else
        echo less than or equal to five
    end