EMT 2390L Lecture 9 Dr. Reyes Reference: The Linux Command Line, W.E. Shotts
Outline Branching with if Branching with case while loop for loop
Branching with if if statement allows you to evaluate a condition and branch based on the results Syntax Example
Test and Expressions An if command will test an expression You may use test or enclose it with [ ] o text expression o [ expression ] When using [ expression ] you must leave a space after opening the first bracket and another space before closing the last bracket [expression] may give unexpected results (notice the lack of spacing)
String Expressions
Integer Expressions
Branching with case Case syntax Case example
while Loop Syntax Example
for Loop C-language Syntax Example
More info Visit the book author’s website at: o More details about decision and repetition statements Examples
Assignments Check the class OpenLab site for new Labs Check Blackboard for new Quizzes Work on your Project Study for the Second Exam (next week)