On Mon, 25 Jul 2005 21:39:50 +0800, <[EMAIL PROTECTED]> wrote:


Can someone suggest a perl command line snippet that will print the last n
lines of a file.


If you are under unix/linux
just use "tail -n" command.

However if you really want to go via Perl command line:

$perl -e '
open FH, "<file" or die $!;
@lines = <FH>;
close FH or die $!;
foreach $i (($#lines - $n) .. $#lines) { print "$lines[$i]\n";}
'


--
Regards,
Edward WIJAYA
SINGAPORE

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to