in reply to how to print first 5 lines of a file

Perl-ish
perl -e 'print ((<>)[0..4])' filename
sh-ish
head -5 filename

HTH

broquaint

Replies are listed 'Best First'.
(tye)Re: how to print first 5 lines of a file
by tye (Sage) on Oct 31, 2001 at 23:55 UTC

    I certainly wouldn't recommend the first solution as, although it looks nice, it will read the entire contents of the file(s) into memory before spitting out the first 5 lines. Better to not even read the 6th line (as demonstrated in other items in this thread), much less allocate memory for it. (:

            - tye (but my friends call me "Tye")