2010. 1. 13. 10:59

[Script]특정문자 변환 - 일괄처리

#!/bin/sh

src="hack_code..."

src1="<script language=javascript><!-- "
src2=" --></script>"
dst=" "
hack="hack_code.txt"
pattern="*htm*|*.php|*.js"

 

if [ "$3" = "" ]; then
        echo $"{Usage; $0 \"`pwd`\" \"find_string\"}"
else

        rm -f $hack
        echo "removed $hack"
        echo ""

        find "$1" -name "*" | egrep "$pattern" | xargs fgrep -l "$2" >> $hack


        for i in `cat $hack`;
        do
                cp -f $i ${i}_bak
                replace "$src" "$dst" -- $i
                replace "$src1" "$dst" -- $i
                replace "$src2" "$dst" -- $i
                sed -i '/^$/d' $i          #빈줄 삭제
#               echo "replaced $i"
        done

        echo ""
        echo "--------------------------------"
        echo "created $hack"
        echo "completed replacing hack_code!!!"
        echo "--------------------------------"
fi

exit;
[출처] http://blog.naver.com/siyang6?Redirect=Log&logNo=30047779296