Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Truncating all lines in file except for the last 20 2

Status
Not open for further replies.

Autosys

Programmer
Jun 1, 2004
90
GB
Hi,

Was wondering if someone knows how to truncate all the contents of a file except for say the last 20 lines in the file.

The amount of lines in the file will never be the same.

Thanks very much!

S
 
you can do it like that:

tail -20 original_file >temp_file
mv temp_file original_file
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top