Why "tail -r" doesn't work

berch%lll-tis.arpa at lll-tis.ARPA berch%lll-tis.arpa at lll-tis.ARPA
Thu Aug 30 07:07:32 AEST 1984


From:  "Michael C. Berch" <berch%lll-tis.arpa at lll-tis.ARPA>

> From:  kemp at noscvax.UUCP (Stephen P. Kemp):
>  tail -r filename
>  lists the file backwards.
>
> From: ihnp4!zehntel!zinfandel!berry
>  Well, on my VAX 750 with 4.1BSD, tail -r of a LARGE file prints the
>  last block or two backwards, then gives up.

I have noticed the same result:
	
	% wc gnu
	    932   7461   45463 gnu
	% tail -r gnu | wc
	     98    651    4096

The answer is that the manual entry for tail(1) is incorrect.
The entry says that with the -r flag, the ENTIRE FILE will be
displayed in reverse order. But the header comment in the code and
the code itself state that ONE INPUT BUFFER'S WORTH of the file
will be put out (backwards, from the end) with the -r flag. 

On our systems (2.9BSD and 4.2BSD) the buffer size (LBIN in
tail.c) is 4097 characters. 

Thus `tail -r' will not put out more than 4097 characters. There
is undoubtedly some way (using the -NN/+NN flags) to get -r to do
the whole file but someone else will have to find it.

Michael Berch
Control Data Corp. / Lawrence Livermore Natl. Laboratory
berch at lll-tis
...ucbvax!lbl-csam!lll-tis!berch



More information about the Comp.unix.wizards mailing list