I am using this code to search and replace text in all php files in current directory:
for file in `find * -type f -name "*.php"`; do awk 'BEGIN { RS="" } FILENAME==ARGV[1] { s="$0" } FILENAME==ARGV[2] { r="$0" } FILENAME==ARGV[3] { gsub(s,r) ; print }' "zsearch" "zreplace" "$file" > "$file"tmp7 && mv "$file"tmp7 "$file";echo "$file"; done
If contents of zsearch file:
<br>
<center><!--LiveInternet counter--><script type="text/javascript"><!--
it's working great, but if contents of zsearch file:
<!--LiveInternet counter--><script type="text/javascript"><!--
document.write("<a href='http://www.liveinternet.ru/click' "+
"target=_blank><img src='http://counter.yadro.ru/hit?t16.6;r"+
escape(document.referrer)+((typeof(screen)=="undefined")?"":
";s"+screen.width+"*"+screen.height+"*"+(screen.colorDepth?
screen.colorDepth:screen.pixelDepth))+";u"+escape(document.URL)+
";"+Math.random()+
"' alt='' title='LiveInternet: показано число просмотров за 24"+
" часа, посетителей за 24 часа и за сегодня' "+
"border=0 width=88 height=31></a>")//--></script><!--/LiveInternet-->
it's not working, not replacing
I think it's due to parenthesis (
symbol in document.write("
Maybe I need to escape other symbols like + or *
?