[net.sources] reversing lines in a file

slg@ukma.UUCP (Sean Gilley) (09/06/85)

Uh.. folks, in our flavor UN*X, (4.2) ``tail'' has a -r option
that does just that.  Don't people _like_ tail? :-)

						Sean.


p.s.  I think it's time this discusion ended . . . or at least got moved
      to net.unix.  These really aren't sources, and I appologise to
      everyone out there for posting here . . . but this is where the
      discussion is.


-- 


Sean L. Gilley  	     Phone: (606) 272-9620 or (606) 257-4613

uucp:	{unmvax,research,boulder,decvax!ucbvax}!anlams!ukma!ukgs!slg
	|| {ihnp4,decvax,ucbvax}!cbosgd!ukma!ukgs!slg

arpa:	 ukma!slg@ANL-MCS.ARPA

stephen@dcl-cs.UUCP (Stephen J. Muir) (09/15/85)

In article <2140@ukma.UUCP> slg@ukma.UUCP (Sean Gilley) writes:
>Uh.. folks, in our flavor UN*X, (4.2) ``tail'' has a -r option
>that does just that.  Don't people _like_ tail? :-)

It's SUPPOSED to go right back to the beginning.  It doesn't on OUR 4.2 system.
Try it on the news history file.  All of the alternative attempts I've seen to
do the same as my program have to read the whole file -- mine doesn't.
-- 
UUCP:	...!seismo!mcvax!ukc!dcl-cs!stephen
DARPA:	stephen%lancs.comp@ucl-cs	| Post: University of Lancaster,
JANET:	stephen@uk.ac.lancs.comp	|	Department of Computing,
Phone:	+44 524 65201 Ext. 4599		|	Bailrigg, Lancaster, UK.
Project:Alvey ECLIPSE Distribution	|	LA1 4YR

greid@adobe.UUCP (Glenn Reid) (09/27/85)

The problem is that tail(1) keeps the lines in a buffer.  However big
the buffer is is the limit to how far you can read the file backwards.
You will note that tail can take an argument, too, but it will never
really read further back than about 300 lines or so...

Glenn

preece@ccvaxa.UUCP (09/30/85)

> [suggests line-by-line reversal of file by sed|num|sort|sed]
> Short, simple, and adequate, besides that fact that it took a grand
> total of 20 seconds to figure out, and maybe 30 to type.  Not bad for a
> 1 minute solution /* Written  3:34 pm  Sep 27, 1985 by
> gregg@okstate.UUCP in ccvaxa:net.sources */
----------
Yes and no.  At least some of the files I have wanted to look at
backwards had millions of lines (that's millions literally, not
hyperbole).  This kind of solution is not terribly useful or
adequate for that use.  It's important to remember that a tool's
availability is only one factor in determining its applicability.
Don't swat flies with an elephant gun and don't drain swimming pools
with a teaspoon unless (1) it's really important that the job get
done and (2) it's really the only tool available.  It's wonderful
that Unix has all these general purpose, composable tools; just
don't forget that sometimes it's APPROPRIATE to build others.

-- 
scott preece
gould/csd - urbana
ihnp4!uiucdcs!ccvaxa!preece