Hacker News new | past | comments | ask | show | jobs | submit login

Ah, thats great learned a new bash trick



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




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: