[Chicago-talk] folding multiple newlines at eof
Brian Katzung
briank at kappacs.com
Tue Aug 16 08:16:46 PDT 2005
Jason Perkins wrote:
> I'm attempting to convert runs of multiple newlines at the end of
> files into a single newline. The following one liner is converting
> all runs of newlines throughout the file to a single newline:
>
> find . -name '*.php' -exec perl -00 -pi -e 's/\n{2,}$/\n/s' {} \;
>
> Can anyone suggest a means of correcting the behaviour? Explanations
> with your fix even more greatly appreciated so that I can figure this
> out on my own next time.
find . -name '*.php' -exec perl -0777 -pi -e 's/\n{2,}$/\n/s' {} \;
Explanation: -00 slurps paragraphs; -0777 slurps files. See -0 option in
man perlrun.
- Brian
More information about the Chicago-talk
mailing list