Advertisement
sheffield

getopts3-param-sh

Apr 15th, 2013
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.30 KB | None | 0 0
  1. #!/bin/bash
  2. while getopts ":a:" opt; do
  3.   case $opt in
  4.     a)
  5.       echo "-a was triggered, Parameter: $OPTARG" >&2
  6.       ;;
  7.     \?)
  8.       echo "Invalid option: -$OPTARG" >&2
  9.       exit 1
  10.       ;;
  11.     :)
  12.       echo "Option -$OPTARG requires an argument." >&2
  13.       exit 1
  14.       ;;
  15.   esac
  16. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement