天天看点

利用unix shell批量替换文件中的特殊字符

利用unix shell批量替换文件中的特殊字符

利用unix shell批量替换文件中的特殊字符

if [ $# -ne 1 ];then

利用unix shell批量替换文件中的特殊字符

    echo 'usage:COMMAND code'

利用unix shell批量替换文件中的特殊字符

    return;

利用unix shell批量替换文件中的特殊字符

fi

利用unix shell批量替换文件中的特殊字符

code=$1

利用unix shell批量替换文件中的特殊字符
利用unix shell批量替换文件中的特殊字符

for FILE in *.sql

利用unix shell批量替换文件中的特殊字符

do 

利用unix shell批量替换文件中的特殊字符
利用unix shell批量替换文件中的特殊字符

    sed s/'#CODE#'/"$code"/g $FILE > /tmp/tmp 

利用unix shell批量替换文件中的特殊字符

    mv /tmp/tmp $FILE     

利用unix shell批量替换文件中的特殊字符
利用unix shell批量替换文件中的特殊字符

    echo "File $FILE dealt." 

利用unix shell批量替换文件中的特殊字符

done

#用cut命令取得文件名12-100位的字符串

filename=`echo $FILE |cut -c12-100`

    本文转自永春博客园博客,原文链接:http://www.cnblogs.com/firstyi/archive/2007/07/12/815267.html,如需转载请自行联系原作者