Guest User

Untitled

a guest
Dec 12th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. usage() { echo "Usage: $0 [-s <45|90>] [-p <string>]" 1>&2; exit 1; }
  2. while getopts ":s:p:" o; do
  3. case "${o}" in
  4. s) s=${OPTARG}
  5. ((s == 45 || s == 90)) || usage
  6. ;;
  7. p) p=${OPTARG}
  8. ;;
  9. *) usage
  10. ;;
  11. esac
  12. done
  13. shift $((OPTIND-1))
  14. if [ -z "${s}" ] || [ -z "${p}" ]; then
  15. usage
  16. fi
  17. echo "s = ${s} and p = ${p}"
  18. $# = total number of arguments / $1 is the first argument / $0 is the script itself.
  19. !# = last argument
Add Comment
Please, Sign In to add comment