User Tools

Site Tools


bash:if...then...else

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
bash:if...then...else [2021/05/28 08:42] – [AND] peterbash:if...then...else [2021/05/28 08:42] (current) peter
Line 114: Line 114:
 else else
 echo "Odd Number" echo "Odd Number"
 +fi
 +</code>
 +
 +----
 +
 +===== 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
 </code> </code>
bash/if...then...else.1622191328.txt.gz · Last modified: 2021/05/28 08:42 by peter

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki