- 论坛徽章:
- 145
|
本帖最后由 jason680 于 2013-12-16 12:17 编辑
回复 11# 代号:军刀
try this one
$ cp test.php.org test.php
$ wc test.php
145 330 4151 test.php
$ diff test.php test.php.org
$ cat config
<HOME_URL> 127.0.0.1
$ perl -i -lape 'BEGIN{for(`cat config`){if(m/(<[^>]+>)\s+(.+)/){$h{$1}=$2}}}{s/(<[^>]+>)/$h{$1} eq ""?$1:$h{$1}/eg}' test.php
$ diff test.php test.php.org
73c73
< var m_url = "127.0.0.1";
---
> var m_url = "<HOME_URL>";
$ wc test.php
145 330 4150 test.php
$ awk 'NR<3||/var m_url/{print NR,$0}{a=b;b=c;c=$0}END{print NR-2,a"\n"NR-1,b"\n"NR,c}' test.php
1 <?php
2
73 var m_url = "127.0.0.1";
143 return unescape(document.cookie.substring(c_start, c_end));
144 }
145
|
|