getopt-test.sh 426 B

1234567891011121314151617181920212223242526
  1. #! /bin/bash
  2. # getopts test
  3. # https://www.computerhope.com/unix/bash/getopts.htm
  4. while getopts :foo OPT; do
  5. case $OPT in
  6. f|+f)
  7. echo $OPT
  8. echo $ARGS
  9. ;;
  10. o|+o)
  11. ;;
  12. o|+o)
  13. ;;
  14. *)
  15. echo "usage: `basename $0` [+-foo} [--] ARGS..."
  16. exit 2
  17. esac
  18. done
  19. shift `expr $OPTIND - 1`
  20. OPTIND=1
  21. echo ARGS $*