bash:if...then...else
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |||
bash:if...then...else [2021/05/28 08:42] – [AND] peter | bash:if...then...else [2021/05/28 08:42] (current) – peter | ||
---|---|---|---|
Line 114: | Line 114: | ||
else | else | ||
echo "Odd Number" | echo "Odd Number" | ||
+ | fi | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== OR ===== | ||
+ | |||
+ | Use **||**. | ||
+ | |||
+ | |||
+ | <code bash> | ||
+ | #!/bin/bash | ||
+ | |||
+ | echo -n "Enter any number:" | ||
+ | read n | ||
+ | |||
+ | if [[ ( $n -eq 15 || $n -eq 45 ) ]] | ||
+ | then | ||
+ | echo "You won" | ||
+ | else | ||
+ | echo "You lost!" | ||
fi | fi | ||
</ | </ |
bash/if...then...else.1622191328.txt.gz · Last modified: 2021/05/28 08:42 by peter