Changes

Jump to: navigation, search

Tutorial12: Shell Scripting - Part 2

737 bytes added, 09:09, 27 July 2020
Additional Logic Statements
Example:
<span style="font-family:courier;">num1=5<br>num2=10<br>if test $num1 –lt $num2<br>then<br> &nbsp;&nbsp;&nbsp;echo “Less Than”<br>else<br>echo &nbsp;&nbsp;&nbsp;“Greater Than or Equal to”<br>fi</span><br><br> [[Image:if-else.png|thumb|right|300px|Example of how an '''if-else''' statement works.]]'''if-elif-else Statements�''' If the test condition returns a TRUE value, then the Linux Commands between then and else statements are executed. �If the test returns a FALSE value, then a new condition is tested, and action is taken if the result is TRUE . Eventually, an action will be taken when the final test condition is FALSE� Example:�� <span style="font-family:courier;">num1=5<br>num2=10<br>if test $num1 –lt $num2<br>then &nbsp;&nbsp;&nbsp;echo “Less Than”<br>elif test $num1 –gt $num2<br>then<br> &nbsp;&nbsp;&nbsp;echo “Greater Than”<br>else &nbsp;&nbsp;&nbsp;echo “Equal to”<br>fi</span><br><br>
===Additional Loop Statements===
13,420
edits

Navigation menu