How do I remove the last two lines in Unix?

How do I remove the last two 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.
19 июн. 2014 г.
 

Tìm kiếm

Back
Top