Created
April 1, 2016 05:34
-
-
Save quickgrid/ef2f7a8c27cd20fd178e6d652a4bf482 to your computer and use it in GitHub Desktop.
This just an example of expression evaluation different way. Also equality and even odd checking in a different way.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Do not use space before and after equal sign. | |
a=1 | |
b=3 | |
sum=`expr $a + $b` | |
sum=$(( $sum + 5 )) | |
echo $sum | |
# If condition, must be closed with fi | |
a=2 | |
b=2 | |
if [ $a -eq $b ];then | |
echo "match" | |
else | |
echo "not match" | |
fi | |
# Check if even | |
read input | |
two=2 | |
val=$(( $input / $two )) | |
val=$(( $val * $two )) | |
#echo $val | |
if [ $val -eq $input ];then | |
echo "Even" | |
else | |
echo "Odd" | |
fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment