Skip to content

Instantly share code, notes, and snippets.

@briandfoy
Created September 9, 2014 13:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save briandfoy/82b4ddd0914634cb8f3d to your computer and use it in GitHub Desktop.
Save briandfoy/82b4ddd0914634cb8f3d to your computer and use it in GitHub Desktop.
#!/usr/bin/perl -s
use vars qw($b);
my @start_sizes = map { -s $_ } @ARGV;
foreach my $file ( @ARGV ) {
if( -d $file ) {
warn "Skipping directory [$file]!\n";
next;
}
my $bak = "$file.bak";
rename( $file => $bak );
open my $in, '<', $bak;
open my $out, '>', $file;
while( <$in> ) {
chomp;
$_ = "" unless /\S/;
s/\s+$//;
print $out ( "$_\n" );
}
unlink $bak unless $b;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment