LINUX命令批量替换文件中的字符串

sed -i "s/abcd/1234/g" `grep abcd -rl /home/data`

 

find /data/web  -type f -exec  sed -i 's#abcd#1234#' {} \;

 

find . -type f |xargs grep 'test'

find ./abroad -name "config.inc.php" -exec sed -i  's#database#localhost#' {} \;

find ./abroad -name "config.inc.php" -exec sed -i  's#database#localhost#g' {} \;

 

//批量插入百度跟踪代码

find . -path './data2' -prune -o -type f -name 'footer.htm' -exec sed -i 's#</body>#<script type="text/javascript">var _bdhmProtocol=(("https:"==document.location.protocol)?" https://":" http://");document.write(unescape("%3Cscript src='"+_bdhmProtocol+"hm.baidu.com/h.js%3F253e47a42e97590881afaab7f667f26f' type='text/javascript'%3E%3C/script%3E"));</script></body>#' {} \;

posted @ 2015-06-19 11:03  Duduer  阅读(867)  评论(0编辑  收藏  举报