I'm using this unix command(in a php file) to remove a certain string and then remove the whitespace left by that string. Unfortunately in many cases, the files get completely erased.
Is there a workaround?
<?php
$dir = "./";
$rmcode = `find $dir -name "*.php"
-type f |xargs sed -i 'somestring' 2>&1`; echo "String removed.<br />\n";
$emptyline = `find $dir -name "*.php"
-type f | xargs sed -i '/./,$!d' 2>&1`; echo "Empty lines removed.<br
/>\n";
?>
Edit
Would this work?
$emptyline = `find $dir -name "*.php"
-type f | xargs sed -i '/./,$!d' 2>&1`; echo "Empty lines removed.<br
/>\n";
becomes
$emptyline = `find $dir -name "*.php"
-type f | xargs sed -i '/\s/,$!d' 2>&1`; echo "Empty lines removed.<br
/>\n";