How do I extract a specific line from a text file in Unix?

Nguyên Lê

New member
How do I extract a specific line from a text file in Unix?
Answer
To extract a range of lines, say lines 2 to 4, you can execute either of the following:
  1. $ sed -n 2,4p somefile. txt.
  2. $ sed ‘2,4! d’ somefile. txt.
 

Tìm kiếm

Back
Top