Changes

Jump to: navigation, search

Tutorial10: Shell Scripting - Part 1

64 bytes removed, 11:28, 10 March 2021
Using Control Flow Statements in Shell Scripts
A '''logic statement''' is used to determine which Linux commands<br>are executed basedon the result of a condition:<br>'''TRUE''' (zero value) or '''FALSE''' (non-zero value).
<table align="right"><tr valign="top"><td>[[Image:logic-1.png|thumb|right|250px|Example of using the '''if''' logic control-flow statement.]]</td><td>[[Image:loop-1.png|thumb|right|250px|Example of using the '''for''' looping control-flow statement.]]</td></table>
<br>
There are several logic statements, but we will just concentrate on the if statement.
'''if-else statement:'''
<br>
[[Image:logic-2.png|thumb|right|200px|Example of how an '''if-else''' control=-flow statement.]]
Unlike using only an ''if'' statement, an '''if-else''' statement take '''two different sets of actions'''<br>based on the results of the test condition.<br><br>
''A <b>loop statement</b> is a series of steps or sequence of statements executed repeatedly zero or more times satisfying the given condition is satisfied.''<br>Reference: https://www.chegg.com/homework-help/definitions/loop-statement-3
[[Image:loop-1.png|thumb|right|210px|Example of using the '''for''' looping control-flow statement.]]
There are several loops, but we will look at the '''for loop''' using a '''list'''.
13,420
edits

Navigation menu