UNIX/ Linux | Conditional Statements | Exp - 9
Conditional Statements
Unix provides a number of relational operators in addition to the logical operators mentioned earlier. These can be used to compare numeric values.
- -lt less than
- -le less than or equal to
- -gt greater than
- -ge greater than or equal to
- -eq equal to
- -ne not equal to
Unix provides a number of ways for conditionally executing the other commands.
These are covered below:
1. The if statements
Example:
if <control command>
then
<statements>
fi
2. The if…else statements
Example:
if <control command>
then
<statements>
else
<statements>
fi
3. The if…elif…else…fi statement
Example:
if <control command>
then
<statements>
elif
then
<statements>
else
<statements
fi
No comments: