in reply to write exact lines of file


Fouth line to end of file:
perl -ne 'print if 4 .. eof' file

Fifth line to tenth:

perl -ne 'print if 5 .. 10' file

Note, in the first example the eof if mainly a visual indicator. The following would work just as well:

perl -ne 'print if 4 .. 1' file perl -ne 'print if 4 .. 0' file # or perl -ne 'print if $. >= 4' file

--
John.

Replies are listed 'Best First'.
Re: Re: write exact lines of file
by Jasper (Chaplain) on Oct 08, 2003 at 13:33 UTC
    From the very first perl golf tournament:

    perl -pe '11..exit'
    (11 for 10,6 for 5, etc)

    Attributable to many.

    And of course, this does the exact opposite of what the OP wanted! Teach me to read the question!

    edit: forgot -e switch, added caveat (thanks jmcnamara)