On 7/25/05, FreeFall <[EMAIL PROTECTED]> wrote:
> try:
> perl -ne '$line=$_;END{print $line}' yourfile
> 
> On Mon, 25 Jul 2005 19:09:50 +0530
> [EMAIL PROTECTED] wrote:
> 
> >
> > hi ,
> >         I am a perl newbie.
> > Can someone suggest a perl command line snippet that will print the last n
> > lines of a file.
> >
> > thanks in advance.
> > regards,
> > Kaushik
> >


perl -e'$n=shift; @x=<>; print splice(@x, -$n), "\n"' 123 yourfile 

but really, on the command line you're better off just using tail if
you have it.

HTH,

-- jay 
--------------------------------------------------
This email and attachment(s): [ x ] blogable; [  ] ask first; [  ]
private and confidential

daggerquill [at] gmail [dot] com
http://www.tuaw.com  http://www.dpguru.com  http://www.engatiki.org

--
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