Shellprog
Shellprog
• Argument passing
• Decision making
• Flow control
• Data input and output
Comments
if command_1 then
command_2
command_3
fi
command_4
Decision Making
if command_1 then
command_2
command_3
else
command_4
command_5
fi
You can also use elif eqv to else followed by if
Data Output
Note:
Zero exit status if the condition is true and a nonzero exit
status if the condition is false
String Operators for test
str1
True if str1 is the same length and
=
contains the same characters as str2
str2
str1 !
= True if str1 is not the same as str2
str2
-n True if the length of str1 is greater than
str1 0 (is not null)
-z
True if str1 is null (has a length of 0)
str1
str1 True if str1 is not null
Numeric Operators for
test
int1 -eq int2 True if int1 is numerically equal to int2