Range of lines from a file

Wednesday, June 05, 2013 , 0 Comments

Below is the command to extract certain lines in Perl based on line numbers.
for eg: If I need to extract lines 5 -10 then i need to do:
perl -lne 'print if($.>=5&&$.<=10) your_file

Also this can done in awk  in a much simpler way:
awk 'NR>=5&&NR<=10 your_file

Classic way of doing this is :
head -10 your_file | tail -6

0 comments: