The script I use to cleanup files with leading and trailing empty lines

This commit is contained in:
Sylvain Pion 2007-03-10 16:47:06 +00:00
parent 05840a8f17
commit 732f926025
1 changed files with 14 additions and 0 deletions

View File

@ -0,0 +1,14 @@
#!/usr/bin/perl
# This script-let removes empty lines at the beginning and at the end of the file.
#
# As complement cleanup, one can also remove trailing white spaces at the end of lines:
# perl -pi.bak -e 's/\s+$/\n/' */examples/*/*.cpp
local($/) = undef;
my $text = <>;
$text =~ s/\A\n+//mg;
$text =~ s/\n+\Z/\n/mg;
print "$text";