Means of trimming files

Gautam Gopalakrishnan thatha at gmail.com
Tue Jun 29 20:09:54 PDT 2004


On Tue, 29 Jun 2004 19:50:25 -0400, Bill Moran <wmoran at potentialtech.com> wrote:
> 
> Gerard Samuel <fbsd-questions at trini0.org> wrote:
> 
> > find ./ -name '*.php' -exec php -r '$f = file_get_contents("{}"); $h =
> > fopen("{}", "wb"); fwrite($h, trim($f)); fclose($h);' \;
> >
> > It did the job perfectly.

$ perl -0 -pi -e 's/\n+$//s' *.php

will edit each .php file and replace it too. If you want a backup, then

$ perl -0 -p -i.bak -e 's/\n+$//s' *.php

Cheers
Gautam


More information about the freebsd-questions mailing list