General
cancel
Showing results for 
Search instead for 
Did you mean: 

How to read a range of lines in a text file

SOLVED
Go to solution
Ridzuan Zakaria
Frequent Advisor

How to read a range of lines in a text file

Hi All,

What shell command could I possibly used to read a range of lines in a text file.

For example: A file contains 500 lines and I would like to read between line 455 to 469 only

Thanks
Ridzuan
quest for perfections
2 REPLIES
Pete Randall
Outstanding Contributor
Solution

Re: How to read a range of lines in a text file

From "Handy One-Liners for Sed" (Attached):

# print section of file based on line numbers (lines 455-469, inclusive)
sed -n '455,469p' # method 1
sed '455,469!d' # method 2


Pete

Pete
Ridzuan Zakaria
Frequent Advisor

Re: How to read a range of lines in a text file

Yes, it works great. Thanks Pete.
quest for perfections