Skip to content

Instantly share code, notes, and snippets.

@suchoudh
Created February 27, 2023 05:28
Show Gist options
  • Select an option

  • Save suchoudh/7527cb15336b4799f2b839fcdbaa5b41 to your computer and use it in GitHub Desktop.

Select an option

Save suchoudh/7527cb15336b4799f2b839fcdbaa5b41 to your computer and use it in GitHub Desktop.
usings options in a bash script for BoD and EoD processes
#!/bin/bash
usage() { echo "$0 usage:" && grep " .)\ #" $0; exit 0; }
[ $# -eq 0 ] && usage
while getopts ":hs:b:e:" arg; do
case $arg in
b) # Specify b value.
echo "runningBoD is ${OPTARG}"
./BoD.sh
;;
e) # Specify e value.
echo "runningEoD is ${OPTARG}"
./EoD.sh
;;
s) # Specify strength, either 45 or 90.
strength=${OPTARG}
[ $strength -eq 45 -o $strength -eq 90 ] \
&& echo "Strength is $strength." \
|| echo "Strength needs to be either 45 or 90, $strength found instead."
;;
h | *) # Display help.
usage
exit 0
;;
esac
done
@suchoudh
Copy link
Author

remember line 4 is different for hs and for b, e

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment