1.根据列表拷贝文件
#!/bin/sh
if [ $# -lt 2 ]; thenecho "Usage: ${0} fileList source_path output_path"
exit 9
fi
fileList=$1
source_path=$2
outputpath=$3
echo ${source_path}
for file in `cat ${fileList}`
do
thisfile=`echo $file|cut -d@ -f1`
bname=`basename $thisfile`
thisdir=`dirname $thisfile`
source_path2=${source_path}"/"${thisdir}
destpath=${outputpath}${thisdir}
echo -e "\n\n"
echo "##### handling ${file} #####################################################"
echo "##### will copy to ${destpath}/${bname}"
echo "cp ${source_path2}"/"${bname} ${destpath}"/"${bname}"
mkdir -p ${destpath}
cp ${source_path2}"/"${bname} ${destpath}"/"${bname}
echo "##### done!!!! ${file} #####################################################"
done
2.根据列表文件对比
#!/bin/sh
if [ $# -lt 2 ]; then
echo "Usage: ${0} fileList source_path other_path"
exit 9
fi
fileList=$1
source_path=$2
outputpath=$3
result=0
echo ${source_path}
for file in `cat ${fileList}`
do
thisfile=`echo $file|cut -d@ -f1`
bname=`basename $thisfile`
thisdir=`dirname $thisfile`
source_path2=${source_path}${thisdir}"/"
destpath=${outputpath}${thisdir}"/"
echo -e "\n\n"
echo "##### handling ${file} #####################################################"
if [ -f ${source_path2}${bname} -a -f ${destpath}${bname} ]; then
echo "diff ${source_path2}${bname} ${destpath}${bname}"
result=`diff ${source_path2}${bname} ${destpath}${bname} | wc -l`
echo "result is ${result}"
if [ ${result} -gt 0 ]; then
echo ${file} >> diff.txt
fi
fi
if [ ! -e ${source_path2}${bname} ]; then
echo ${source_path2}${bname} >>notInLeft.txt
fi
if [ ! -e ${destpath}${bname} ]; then
echo ${destpath}${bname} >>notIndRight.txt
fi
echo "##### done!!!! ${file} #####################################################"
done
2.1 找出文件区别打印出来
#!/bin/sh
if [ $# -lt 2 ]; then
echo "Usage: ${0} fileList source_path other_path"
exit 9
fi
fileList=$1
source_path=$2
outputpath=$3
result=0
echo ${source_path}
for file in `cat ${fileList}`
do
thisfile=`echo $file|cut -d@ -f1`
bname=`basename $thisfile`
thisdir=`dirname $thisfile`
source_path2=${source_path}${thisdir}"/"
destpath=${outputpath}${thisdir}"/"
echo -e "\n\n"
echo "##### handling ${file} #####################################################"
echo "diff ${source_path2}${bname} ${destpath}${bname}"
#result=`diff ${source_path2}${bname} ${destpath}${bname} | wc -l`
echo "-----------------------------------------------------">>diffcontent
echo -e "${source_path2}${bname} --> \n${destpath}${bname}" >>diffcontent
echo "-----------------------------------------------------">>diffcontent
diff ${source_path2}${bname} ${destpath}${bname} >>diffcontent
result=0
echo "result is ${result}"
if [ ${result} -gt 0 ]; then
echo ${file} >> diff.txt
fi
echo "##### done!!!! ${file} #####################################################"
done
3.根据列表提交SVN
#!/bin/sh
if [ $# -lt 4 ]; then
echo "Usage: ${0} fileList svntagpath inputpath commit_comment"
exit 9
fi
fun_svn_tag(){
f1_c=`svn info $1 | grep "URL" | awk -F " " '{print $2,$NF}' | grep $2 | wc -l`
return ${f1_c}
}
fileList=$1
svntag=$2
inputpath=$3
comment=$4
#run_flag="n"
if [ ${inputpath}"x" == ".x" ]; then
echo "the inputpath cannot be "."!!!! exit(1)"
exit 1;
fi
echo ${svntag}
tagname=`echo ${svntag} | awk -F "/" '{printf $NF}'`
for file in `cat ${fileList}`
do
thisfile=`echo $file|cut -d@ -f1`
bname=`basename $thisfile`
thisdir=`dirname $thisfile`
svnpath="."${thisdir}
destpath=${inputpath}"/"${thisdir}
echo -e "\n\n"
echo "##### handling ${file} #####################################################"
echo "##### will copy from to ${destpath}/${bname}"
echo "checking "${destpath}"/"${bname}
if [ ! -f ${destpath}"/"${bname} ]; then
echo "the file "${destpath}"/"${bname}" is not exitsed !!!!, this file will be ignore"
echo "file "${file}" is not exitsed !!!!!" >> error.log
continue
fi
echo "checking "${svnpath}"/"${bname}
if [ ! -f ${svnpath}"/"${bname} ]; then
echo "file not exits, it will run svn checkout now !!!!"
echo "svn co ${svntag}${thisdir} ${svnpath}"
svn co ${svntag}${thisdir} ${svnpath}
else
#judge whether path is for the correct svn path
echo "the path is already exited"
fun_svn_tag ${svnpath} ${tagname}
if_flag=$?
if [ ${if_flag} -lt 1 ]; then
echo "the path is not for this tag "${tagname}", it will be remove and checkout again!!"
svnpathhead=`echo ${svnpath} | awk -F "/" '{print $2}'`
echo "rm -rf ${svnpathhead}"
rm -rf ${svnpathhead}
#chekout out
echo "svn co ${svntag}${thisdir} ${svnpath}"
svn co ${svntag}${thisdir} ${svnpath}
fi
fi
if [ ! -f ${svnpath}"/"${bname} ]; then
echo "file is not existed at svn ! it will be execute svn add"
echo "cp ${destpath}"/"${bname} ${svnpath}"/"${bname}"
cp ${destpath}"/"${bname} ${svnpath}"/"${bname}
echo "svn add ${svnpath}"/"${bname}"
echo ${file} >> addlist.txt
svn add ${svnpath}"/"${bname}
if [ $? != 0 ]; then
echo "file "${file}" is fail !!!!!" >> error.log
fi
else
echo "the file is existed in svn alreary, it will be performed svn update"
echo "svn update "${svnpath}"/"${bname}
svn update ${svnpath}"/"${bname}
echo "cp ${destpath}"/"${bname} ${svnpath}"/"${bname}"
cp ${destpath}"/"${bname} ${svnpath}"/"${bname}
fi
echo "svn commit -m "${comment}" "${svnpath}"/"${bname}
#printf "execute above command? (y/n):"
#read ${run_flag}
#
#if [ ! ${runf_flag} == "y" ]; then
# continue
#fi
svn commit -m ${comment} ${svnpath}"/"${bname}
if [ $? != 0 ]; then
echo "file "${file}" is fail !!!!!" >> error.log
fi
echo ${file} >> committed.txt
echo "##### done!!!! ${file} #####################################################"
done