Last active
August 29, 2015 14:19
-
-
Save TylerLH/d87f94ca1a36e2833193 to your computer and use it in GitHub Desktop.
Divide 2 numbers
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 | |
if [ $# -ne 2 ] | |
then | |
echo "You must enter 2 arguments. You entered $#". | |
exit 2 | |
fi | |
if [ $(echo $1 | grep "[0-9]") ] | |
then | |
if [ $(echo $2 | grep "[0-9]") ] | |
then | |
if [ $2 -eq 0 ] | |
then | |
echo "Zero entered for arg 2" | |
exit 2 | |
else | |
echo $1 "/" $2 "=" $[$1/$2] | |
exit 0 | |
fi | |
else | |
echo "The second arg isn't a number." | |
exit 2 | |
fi | |
else | |
echo "The first arg isn't a number." | |
exit 2 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment