# example of use of getopt to handle options to a shell script invocation args=$(getopt npt $*) if [ $? != 0 -o $# -lt 2 ] ; then echo "Usage: $(basename $0) {-p} {-n} {-t} PATTERN NEWPATTERN" echo " echo " -p rewrites PNG to png" echo " -n sequentially numbers matching files with" echo " NEWPATTERN as base filename" echo " -t test mode: show what you'll do, don't do it." exit 0 fi set -- $args for i do case "$i" in -n ) renumber=1 ; shift ;; -p ) fixpng=1 ; shift ;; -t ) doit=0 ; shift ;; -- ) shift ; break ;; fi # Released under GNU General Public License 3 by celeste:crystalfaery 2011-02-07 00:33:18+00:00 # http://www.crystalfaeries.net/linux/bin/get_options.txt