cpdir.sh
时间:2007-12-25 来源:061107
#cpdir.sh
#!/bin/sh
usage()
{
echo "cpdir.sh source destination"
} if [ $# -ne 2 ]; then
usage
exit 0
fi srcdir=$1
desdir=$2
mkdir $desdir if [ ! -d ${srcdir} ]; then
usage
echo "error: source ${srcdir} not dir"
exit
fi if [ ! -d ${desdir} ]; then
usage
echo "error: distination ${desdir} not dir"
exit
fi processid=$$ find ${srcdir}/* -type d | /usr/bin/tee /tmp/srcdir_tmp_${processid}.txt
sed "s/^${srcdir}/${desdir}/g" /tmp/srcdir_tmp_${processid}.txt >/tmp/srcdir_${processid}.txt rm -rf ${desdir}/*
for subdir in `cat /tmp/srcdir_${processid}.txt`
do
{
mkdir ${subdir}
}
done find ${desdir}/* -type d | /usr/bin/tee /tmp/desdir_${processid}.txt diff /tmp/desdir_${processid}.txt /tmp/srcdir_${processid}.txt
rm -f /tmp/srcdir_${processid}.txt
rm -f /tmp/desdir_${processid}.txt
rm -f /tmp/srcdir_tmp_${processid}.txt
usage()
{
echo "cpdir.sh source destination"
} if [ $# -ne 2 ]; then
usage
exit 0
fi srcdir=$1
desdir=$2
mkdir $desdir if [ ! -d ${srcdir} ]; then
usage
echo "error: source ${srcdir} not dir"
exit
fi if [ ! -d ${desdir} ]; then
usage
echo "error: distination ${desdir} not dir"
exit
fi processid=$$ find ${srcdir}/* -type d | /usr/bin/tee /tmp/srcdir_tmp_${processid}.txt
sed "s/^${srcdir}/${desdir}/g" /tmp/srcdir_tmp_${processid}.txt >/tmp/srcdir_${processid}.txt rm -rf ${desdir}/*
for subdir in `cat /tmp/srcdir_${processid}.txt`
do
{
mkdir ${subdir}
}
done find ${desdir}/* -type d | /usr/bin/tee /tmp/desdir_${processid}.txt diff /tmp/desdir_${processid}.txt /tmp/srcdir_${processid}.txt
rm -f /tmp/srcdir_${processid}.txt
rm -f /tmp/desdir_${processid}.txt
rm -f /tmp/srcdir_tmp_${processid}.txt
相关阅读 更多 +