UNIX


CPTDIR


1 : 2 # &(#) cptdir v.1.0 Copy a directory tree Autor: Russ Sage 4 if [ $# -lt 2 -o $# -gt 3 ] 5 then echo "cptdir: argument error" >&2 6 echo "usage: cptdir [-s] srcdir desdir" >&2 7 echo " -s silent mode" >&2 8 exit 1 9 fi 11 if [ "$1" ="-s" ] 12 then OPT="-pd" 13 shift 14 else OPT="-pdv" 15 fi 17 SRC=$1 18 DEST=$2 19 umask 0 21 if [ -d $DEST ] 22 then echo "\"$DEST\" already exist. Remove it? (y/n): \c" 23 read CMD 24 if [ "$CMD" = "y" ] 25 then rm -rf $DEST 26 mkdir $DEST 27 fi 28 else mkdir $DEST 29 fi 31 if [ "`echo $DEST|cut -c1`" = "/" ] 32 then cd $SRC 33 find . -print | sort | cpio $OPT $DEST 34 else PWD=`pwd` 35 cd $SRC 36 find . -print | sort | cpio $OPT $PWD/$DEST 37 fi