in reply to peeling the top 10 lines from a file

#UNIX head: #head -10 'filename' #Perl equivalent: #perl -pe '$.>10&&exit' 'filename'


Replies are listed 'Best First'.
Re^2: peeling the top 10 lines from a file
by crashtest (Curate) on May 16, 2005 at 17:53 UTC
    I was going to point out head if nobody else had. Having "grown up" on Windows systems, it took me a while to figure out how many useful tools a UNIX system provides. You don't always need the Perl Swiss Army Knife if the right size screwdriver is just lying around already.

    To check for empty lines (as the original post suggests), you can count them using grep:
    head -10 filename | grep -c '^$'