One day, I got sick of typing up the whole command over and over.
I needed to write a script that took in one mandatory argument and a second optional argument.
To make the second argument optional, use the "-z" operator checks if a string is empty. The "-n" operator checks for the string being not empty.
if [ -z "$1" ]; then
echo "You need at least 1 argument"
if [ -z "$2" ]; then
CMD="command something $1 -some -flags $DOMAIN"
Remember to "chmod +x filename" to make it executable.
Now you can begin performing all crazy sorts of bash-fu.
[ Source ]