Changes

Jump to: navigation, search

Tutorial12: Shell Scripting - Part 2

7 bytes added, 08:11, 27 July 2020
Additional Logic Statements
<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-elif-else.png|thumb|right|300px|Example of how an '''if-elif-else''' statement works.]]'''if-elif-else Statements�Statements'''
If the test condition returns a TRUE value, then the Linux Commands between <br>then and else statements are executed. <br><br>If the test returns a FALSE value, then a new condition is tested, <br>and action is taken if the result is TRUE . Eventually, an action will be taken when the final test condition is FALSE�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>
13,420
edits

Navigation menu