home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cdrom.com/pub/cdrom/
/
cdrom.tar
/
cdrom
/
cdroms
/
x11r5
/
copydir.sh
< prev
next >
Wrap
Linux/UNIX/POSIX Shell Script
|
1994-04-04
|
665b
|
22 lines
#! /bin/sh
test $# = 2 || { echo usage: copydir.sh \<src-dir\> \<dest-dir\> >&2 ; exit 1 ; }
FROM=$1
TO=$2
test -d $FROM || { echo "$FROM does not exist" >&2 ; exit 1 ; }
test -f $FROM/00_TRANS.TAB || { echo "$FROM/00_TRANS.TAB does not exist" >&2; exit 1;}
test -d $TO || mkdir $TO || { echo "Cannot create $TO" >&2 ; exit 1 ; }
TMP=/tmp/`echo $FROM | sed -e s,/,-,g`
set -xe
sed -e \
"/^-/s,^[^ ]* \([^ ]*\) *\(.*\)$,test -f $TO/\2 || cp $FROM/\1 $TO/\2,"\
-e \
"/^d/s,^[^ ]* \([^ ]*\) *\(.*\)$,test -d $TO/\2 || mkdir $TO/\2 ; $0 $FROM/\1 $TO/\2,"\
-e '1 i\
#! /bin/sh'\
-e '1 i\
set -xe' < $FROM/00_TRANS.TAB > $TMP
chmod 777 $TMP
$TMP
rm -f $TMP
exit 0