Skip to content

Instantly share code, notes, and snippets.

@TylerLH
Last active August 29, 2015 14:19
Show Gist options
  • Save TylerLH/d87f94ca1a36e2833193 to your computer and use it in GitHub Desktop.
Save TylerLH/d87f94ca1a36e2833193 to your computer and use it in GitHub Desktop.
Divide 2 numbers
#!/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