DrSchool Learn coding, fast.
EN AR BN CS DE EL Search

Conditionals — Example 65

Quick explanation + ready code for: Conditionals.

Shell Conditionals Back to examples
Back to language
Syntax: Conditionals in Shell. ID: #65

Code

n=14
if (( n % 2 == 0 )); then echo even; else echo odd; fi

Notes

You can copy this snippet and adapt it. For advanced, add real-world inputs, edge cases, and tests.