#!/bin/sh # movedir.sh - Move a directory tree from one place to another # # Time-stamp: " " # $Id:$ # Usage function usage() { echo echo "usage: $0 /source/directory /dest/directory" echo echo "Contents of /source/directory will be copied to /dest/directory." echo "Requires /dest/directory to be empty." echo exit $1 } # Check number of parameters if [ $# != 2 ]; then usage 1 fi # Grab the parameters SRC=$1 DST=$2 # Verify there are files in the source if [ $(find ${SRC}/* | wc -l) -le 0 ] ; then echo echo "ERROR: $SRC contains no files" usage 1 fi # Verify the destination is empty if [ $(find ${DST}/* ! -path ${DST} ! -name lost+found | wc -l) -gt 0 ]; then echo echo "ERROR: $DST is not empty" usage 1 fi # Move the directores (cd $SRC; tar cf - . ) | (cd $DST; tar xvfp -) # EOF