#! /bin/ksh # # Author: Mike Fleming mike@tauzero.co.uk # # tarzip - tar and zip up a directory # # tarzip dirname while getopts v opt do case $opt in v) TAROPT=-v;; *) echo "Usage: tarzip [ -v ] dirname" return 1;; esac done shift $((OPTIND - 1)) if [[ "$1" == "" ]] then echo No directory specified return 1 fi if [[ ! -d $1 ]] then echo $1 is not a directory return 1 fi BNAME=$(basename $1) DNAME=$(dirname $1) CURRDIR=$PWD cd $DNAME tar -cf $TAROPT - $BNAME | gzip -c > $BNAME.tar.gz cd $CURRDIR echo "Created $BNAME.tar.gz in $DNAME"