Here i paste a perl script to delete last Two Lines. If you want
delete more lines in a file you can specify it.
use File::ReadBackwards;
my $filename = 'test.txt';
my $Lines_to_truncate = 2; # Here the line to truncate is mean Remove
only Last Two Lines
my $bw = File::ReadBackwards->new( $filename )
or die "Could not read backwards in [$filename]: $!";
my $lines_from_end = 0;
until( $bw->eof or $lines_from_end == $Lines_to_truncate )
{
print "Got: ", $bw->readline;
$lines_from_end++;
}
truncate( $filename, $bw->tell );
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/