分类: LINUX
2011-09-02 19:05:24
#!/bin/bash if [ $# -ne 2 ] then cat < Example: $0 old-str new-str EOF exit fi #list=`find -type f -name "*.[hc]"` list=`grep $1 . --include="*.[hc]" -rnl` echo $list for i in $list; do # sed --in-place -e 's/'$1'/'$2'/g' $i; sed --in-place -e '/'$1'/ s//'$2'/g' $i done |
diff -NuraBb --exclude='*.orig' --exclude='*.o' --exclude='*.ko' \ --exclude='*.cmd' --exclude='*.o' --exclude='CVS' --exclude='.svn' \ --exclude='.git' --exclude='*.git' --exclude='*.mod' --exclude='.*' \ --exclude='*.rej' --exclude='*.orig' --exclude='*.symvers' \ --exclude='debian' --exclude='*.a' --exclude='*.mod.c' \ --exclude='System.map' --exclude='*.so' -urN \ $1 $2 >different.patch |
#!/bin/bash #Format the source code(s) astyle --style=linux --indent=spaces=4 --brackets=linux \ --indent-col1-comments --pad-oper --pad-header \ --unpad-paren --add-brackets --convert-tabs \ --mode=c --lineend=linux $@ >/tmp/astyle.log #Deal with the log of astyle sed -i -e 's;formatted ;;g' /tmp/astyle.log; sed -i -e 's;unchanged\* ;;g' /tmp/astyle.log; #Define global variable DIR=$PWD #Get the directory of the source code(s) to generate the patch line=`sed -n 1p /tmp/astyle.log` DIR=`dirname $line` #We needn't /tmp/astyle.log any more, delete it. rm -rf /tmp/astyle.log #Check if the patch file existed if [ -e ${DIR}/linux_style.patch ]; then rm -rf ${DIR}/linux_style.patch fi #Generate the patch DATE_TIME=$(date '+%H.%M.%S.%N') suffix=.orig list=`find ${DIR} -name "*"${suffix}` echo $list for i in $list; do filename=`echo $i | sed 's/'${suffix}'$//'`; diff -Nura $filename${suffix} $filename >> ${PWD}/linux_style-${DATE_TIME}.patch; rm -rf $filename${suffix} done |