in reply to removing lines that are in the end of a file
The answers so far do not seem to have noticed the first line which also contains "SIL".
This is pretty trivial using File::ReadBackwards:
#! perl -slw use strict; use File::ReadBackwards; my $file = $ARGV[ 0 ]; tie *BW, 'File::ReadBackwards', $file; my $lastpos = -s( $file ); while( <BW> ) { last unless /SIL/; $lastpos = tell( BW ) } truncate $file, $lastpos; close BW;
A sample run:
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: removing lines that are in the end of a file
by bhargavkanakiya (Initiate) on Apr 19, 2013 at 09:33 UTC | |
by BrowserUk (Patriarch) on Apr 19, 2013 at 12:46 UTC |