HP3000-L Archives

January 2001, Week 2

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
"COLE,GLENN (Non-HP-SantaClara,ex2)" <[log in to unmask]>
Reply To:
COLE,GLENN (Non-HP-SantaClara,ex2)
Date:
Wed, 10 Jan 2001 14:42:40 -0800
Content-Type:
text/plain
Parts/Attachments:
text/plain (24 lines)
Tony Newton writes:

> I can't remember for the life of me how to print an entire file minus the
> last 'x' lines on UX 10.20.  I played with tail for awhile but that didn't
> get me anywhere.  Any suggestions.

There are at least two choices.

One is 'head' (suggested by Bill Proudfoot), and another is 'sed'.

The following examples assume you want to print all but the final
three (3) lines of a file named xxx.

   totlines=`wc -l < xxx`
   head -`expr $totlines - 3` xxx

   totlines=`wc -l < xxx`
   sed -n "1,`expr $totlines - 3`p" xxx

No doubt there are other, more elegant solutions.
This should get you started, though.

--Glenn

ATOM RSS1 RSS2