The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM



View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #4 (permalink)  
Old 04-18-2008
ShawnMilo ShawnMilo is offline
Registered User
 

Join Date: Jun 2006
Posts: 159
Assuming you want to remove the last 22 lines:

Code:
tac filename | tail -n +23 | tac
What this does:

1. Reverse the file.
2. Take all but the first 22 lines.
3. Reverse the file again (back to the original order).

Note that the number tells it at which line to start, so 2 will cut off the first line, 50 will cut off 49 lines, etc.

ShawnMilo
Reply With Quote