Re: how to use sed to delete last lines of a file

From: Frank Chiavoni (Frank.Chiavoni@OIT.STATE.NJ.US)
Date: Wed Oct 09 2002 - 14:32:22 EDT


Simple???

wc -l inputfile | awk '{x=$1-4; print x}' | xargs -i sed '{},$d' inputfile

-----Original Message-----
From: IBM AIX Discussion List [mailto:aix-l@Princeton.EDU]On Behalf Of
Michelle DeVault
Sent: Wednesday, October 09, 2002 2:00 PM
To: aix-l@Princeton.EDU
Subject: Re: how to use sed to delete last lines of a file

That deletes the last line, but how about deleting
more than that, say the last four lines of a file?

--- "Naylor, Jim" <Jnaylor@SCHNUCKS.COM> wrote:
> sed '$d' inputfile > outputfile
>
> -----Original Message-----
> From: Michelle DeVault [mailto:adsmigmo@YAHOO.COM]
> Sent: Wednesday, October 09, 2002 10:18 AM
> To: aix-l@Princeton.EDU
> Subject: how to use sed to delete last lines of a
> file
>
>
> Is there a simple syntax for sed to delete the last
> lines of a file without having to count the number
> of
> lines in the file?
>
> __________________________________________________
> Do you Yahoo!?
> Faith Hill - Exclusive Performances, Videos & More
> http://faith.yahoo.com

__________________________________________________
Do you Yahoo!?
Faith Hill - Exclusive Performances, Videos & More
http://faith.yahoo.com



This archive was generated by hypermail 2.1.7 : Wed Apr 09 2008 - 22:16:15 EDT