#! /bin/bash - function mycopydir( ) { if ! [ -d $2 ] then rm -rf $2 cp -rf $1 $2 echo "copy $1 to $2" return 0 fi allfiles=$(ls $1) for one in $allfiles do if [ -d $1"/"$one ] then mycopydir $1"/"$one $2"/"$one continue fi if [ -f $1"/"$one ] then if ! [ -f $2"/"$one ] then rm -rf $2"/"$one cp -f $1"/"$one $2"/"$one echo "copy $1/$one to $2/$one " fi fi done } if [ $# -lt 2 ] then echo "must two argv!" exit 0 fi if ! [ -d $1 ] then echo $1"not exist!" exit 0 fi mycopydir $1 $2 exit 0 //shell/1295