How do you display the nth line of a file in Unix?

Hoàng Minh An

New member
How do you display the nth line of a file in Unix?
Answer
Below are three great ways to get the nth line of a file in Linux.
  1. head / tail. Simply using the combination of the head and tail commands is probably the easiest approach. …
  2. sed. There are a couple of nice ways to do this with sed . …
  3. awk. awk has a built in variable NR that keeps track of file/stream row numbers.
 

Tìm kiếm

Back
Top