Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site brl-tgr.ARPA Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!panda!talcott!harvard!seismo!brl-tgr!tgr!RSanders@DENVER.ARPA From: RSanders@DENVER.ARPA Newsgroups: net.sources Subject: cpdir shell script & man page for 4.2 BSD Message-ID: <10123@brl-tgr.ARPA> Date: Mon, 22-Apr-85 19:32:29 EST Article-I.D.: brl-tgr.10123 Posted: Mon Apr 22 19:32:29 1985 Date-Received: Wed, 24-Apr-85 03:21:06 EST Sender: news@brl-tgr.ARPA Lines: 47 Yes, this is a trivial hack, but somebody had to do it. Cut at the dotted lines. Works for us on VAX/4.2 BSD - others, beware. -- Rex ............................................................................ .TH CPDIR 1 LOCAL "USGS Pacific Marine Geology" .SH NAME cpdir - copy directory (and subdirectories) .SH SYNOPSIS .B cpdir dir1 dir2 .SH DESCRIPTION .I Dir1 is copied into .IR dir2 , complete with files and subdirectories. .I Dir2 is created, if necessary. .PP Modify and access times of files are preserved; modify and access times of .I dir2 (if created) and any subdirectories are not preserved. Ownership and access modes are preserved for all files and directories, except for .I dir2 if it is created. .SH "SEE ALSO" cp(1), mkdir(1), mv(1), tar(1) .SH AUTHOR Rex Sanders, U.S. Geological Survey, Pacific Marine Geology ............................................................................... #! /bin/sh # cpdir - copies an existing directory (and subtree) to a new dir # Rex Sanders, USGS Pacific Marine Geology if [ $# -ne 2 ] then echo "Usage: cpdir olddir newdir" exit 1 fi owd=`pwd` if test -d $2 then cd $1 && tar cf - . | ( cd $owd; cd $2; tar xf - ) else mkdir $2 && cd $1 && tar cf - . | ( cd $owd; cd $2; tar xf - ) fi