Korn shell Tutorials :Comparision in scripting

Korn shell Tutorials :Comparision in scripting
To compare strings one uses "=" for equal and "!=" for not equal.
To compare numbers one uses "-eq" for equal "-ne" for not equal as well as "-gt" for greater than
and "-lt" for less than.
if [[ $name = "John" ]];then
# commands....
fi
if [[ $size -eq 1000 ]];then
# commands....
fi
With "&&" for "AND" and "||" for "OR" one can combine statements:
if [[ $price -lt 1000
$name = "Hanna" ]];then
# commands....
fi
if [[ $name = "Fred" && $city = "Denver" ]];then
# commands....
fi

No comments:

 
Top Blogs