The UNIX and Linux Forums
>
Top Forums
>
Shell Programming and Scripting
delete n last lines of a file
User Name
Remember Me?
Password
Google UNIX.COM
Forums
Portal
Register
Rules & FAQ
Contribute
Members List
Arcade
Search
Today's Posts
Mark Forums Read
Thread
:
delete n last lines of a file
View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
#
8
(
permalink
)
05-17-2008
ShawnMilo
Registered User
Join Date: Jun 2006
Posts: 154
This is not memory-intensive, and will work.
Code:
cat filename | perl -ne 'push(@a, $_); print shift(@a, ) if $#a >=3 ;'
ShawnMilo
View Public Profile
Find all posts by ShawnMilo