in reply to text sorting question, kinda
Ovid's answer looked interesting too, but I try not to take things from people on crack. <big grin>
Update: Thanks as well to other fine Monks who offered answers.
cheers,
ybiC
#!/usr/bin/perl -w # parse a log file and move lines with important text to top # of file while keeping sequence within each of two sections: # important and not-so-important use strict; my $infile = '/dir/file.in'; my $outfile = '/dir/file.out'; my @important; my @normal; open IN, "$infile" or die "Couldn't open $infile"; open OUT, ">$outfile" or die "Couldn't open $outfile"; while (<IN>) { s/unwanted text//g; # strip unwanted text s/more unwanted text//g; # strip unwanted text s/^\s+//g; # remove empty lines (/important text/) ? push @important, $_ : push @normal, $_; } print OUT @important; print OUT @normal; close IN or die "Couldn't close $infile"; close OUT or die "Couldn't close $outfile"; # END
|
|---|