#! /bin/sh USAGE="Usage: `basename $0` [-hv] [-o arg] args" # we want at least one parameter (it may be a flag or an argument) if [ $# -eq 0 ]; then echo $USAGE >&2 exit 1 fi # parse command line arguments while getopts hvo: OPT; do case "$OPT" in h) echo $USAGE exit 0 ;; v) echo "`basename $0` version 0.1" exit 0 ;; o) OUTPUT_FILE=$OPTARG ;; \?) # getopts issues an error message echo $USAGE >&2 exit 1 ;; esac done shift `expr $OPTIND - 1` # access additional parameters through $@ or $* as usual or using this loop: for PARAM; do echo $PARAM done # EOF