cpdiff shell

#!/bin/ksh

if [ $# != 1 ] || [ -z "$1" ]
then
        echo ">>> Usage:cpdiff FileName|\"*\""
        exit 1
fi

file_list=$1

src_dir=$PWD

view_dir=${src_dir##*/code/durian/durian_main}


echo "@@@@@@@@ begin to diff and copy file @@@@@@@@"
echo "" 
for file in ${file_list[@]}
        do
                if [ ! -e "$file" ]
                then
                	echo "$file does not exist."; 
                	continue
                fi

                if [ ! -e "$view_dir/$file" ]
                then
                	echo "$view_dir/$file does not exist."; 
                	continue
                fi

                diff $file $view_dir/$file > /dev/null
                if [[ $? -eq 0 ]]
                then
                        echo $file is same
                else
                        echo $file is not same
                        cpcode $file
                	if [[ $? -eq 0 ]]
			then
                        	echo "OK copy to $view_dir"
			fi
                fi
        done

exit 0


 

你可能感兴趣的:(cpdiff shell)