Fetching lines partially using command line

Published on July 5, 2010 by Saeid Zebardast

To see some part of a text file, use the following methods:

1- To get top 20 lines of a file header, use:

$ head -n20 FILE

2- To get 30 line of bottom of a file, use:

$ tail -n30 FILE

3- If you want to print some lines that they are not in the first part or in the last part of a file, you can use:

$ more +num10 FILE | head -n20

The previous command print from line 10 to 30 (20 lines) of FILE.

Tags: ,
Posted in Linux

Leave a Reply

Categories

Archives