Skip to content

Instantly share code, notes, and snippets.

@jpcaparas
Created May 6, 2019 05:45
Show Gist options
  • Save jpcaparas/0a1583ffa91b77fe5a305e6c6c73a073 to your computer and use it in GitHub Desktop.
Save jpcaparas/0a1583ffa91b77fe5a305e6c6c73a073 to your computer and use it in GitHub Desktop.
getopts example
#!/bin/bash
while getopts ":f:b:" o; do
case "${o}" in
f)
foo=${OPTARG}
;;
b)
bar=${OPTARG}
;;
esac
done
foo=${foo:-Foo!}
bar=${bar:-Bar!}
echo "${foo} and ${bar}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment