Operating System - HP-UX
1752522 Members
4704 Online
108788 Solutions
New Discussion юеВ

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 2
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