Anybody have a quick easy way to do recursive find and replace?
Here is my complicated stab at it, but I must say this was a pain to
write. I think there must be a utility for doing this to make this
much much much easier?
echo '#!/usr/local/bin/php -q' > /tmp/fix.php
chmod 755 /tmp/fix.php
echo '<?php
if (! file_exists($argv[1]) ) {
die($argv[1]." does not exist");
}
$input = file_get_contents($argv[1]);
$find = array(
"&10\.0\.0\.52&i"
);
$replace = array(
"10.0.0.68"
);
$input = preg_replace($find, $replace, $input);
$fp = fopen($argv[1], "w");
fputs($fp, $input);
fclose($fp);
?>' >> /tmp/fix.php
egrep -lr '10.0.0.52' * | \
egrep -v 'CVS|\.#|HTMLArea|FCK|vdm' > /tmp/db.tmp1
for i in `cat /tmp/db.tmp1`; do
/tmp/fix.php $i
echo $i
done
---------------------------------------------------
PLUG-discuss mailing list -
PLUG-discuss@lists.plug.phoenix.az.us
To subscribe, unsubscribe, or to change you mail settings:
http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss