How do I remove the last 10 lines in Unix?

Nguyễn Tân

New member
How do I remove the last 10 lines in Unix?
Answer
It’s a little roundabout, but I think it’s easy to follow.
  1. Count up the number of lines in the main file.
  2. Subtract the number of lines you want to remove from the count.
  3. Print out the number of lines you want to keep and store in a temp file.
  4. Replace the main file with the temp file.
  5. Remove the temp file.
 

Tìm kiếm

Back
Top