Operating System - Linux
1828667 Members
1920 Online
109984 Solutions
New Discussion

Bug/Limitation in tail ??

 
SOLVED
Go to solution
Daavid Turnbull
Frequent Advisor

Bug/Limitation in tail ??

I want to grab the last "number" of lines of a text file. The file is moderately large and between 100 and 200 columns wide.

In this particular instance it is always return me just 81 lines, the first of which is incomplete (missing the start of the line).

Using wc to summarise here is a copy of my shell window:
______________

> wc ReportCalls.tmp.5872.tmp
37758 730646 9059587 ReportCalls.tmp.5872.tmp
> tail -1200 ReportCalls.tmp.5872.tmp | wc
81 1727 20480
______________

Is there a limit of 20K on tail?

Can it be increased?

Is there a way around this?

It is within the context of a Perl script. doubtless there is a better way to do this using Perl so any hints and suggestions as to how best to do it in Perl would also be appreciated.
Behold the turtle for he makes not progress unless he pokes his head out.
7 REPLIES 7
Steven E. Protter
Exalted Contributor

Re: Bug/Limitation in tail ??

whence tail
which tail
what tail

Lets get some version information. There may be a patch out there for you.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Daavid Turnbull
Frequent Advisor

Re: Bug/Limitation in tail ??

It is a pretty vanilla system and up to date patch bundle wise...
__________

> whence tail
/usr/bin/tail
> which tail
/usr/bin/tail
> what `whence tail`
/usr/bin/tail:
$Revision: 82.2 $
Behold the turtle for he makes not progress unless he pokes his head out.
Daavid Turnbull
Frequent Advisor

Re: Bug/Limitation in tail ??

and
_________

> uname -a
HP-UX chccm1 B.11.00 U 9000/800 2016741259 unlimited-user license
Behold the turtle for he makes not progress unless he pokes his head out.
Daavid Turnbull
Frequent Advisor

Re: Bug/Limitation in tail ??

grr... it seems to be a limitation.

From the man page:
__________


WARNINGS
Tails relative to end-of-file are stored in a 20-Kbyte buffer, and
thus are limited in length. Therefore, be wary of the results when
piping output from other commands into tail.

__________


I guess I need to use something else.
Behold the turtle for he makes not progress unless he pokes his head out.
Hein van den Heuvel
Honored Contributor

Re: Bug/Limitation in tail ??


Right, you may need to find a better (gnu) tail, or use an alternative for example with awk or perl.


Using awk (minimally tested):

awk 'BEGIN{w=3}END{i=NR-w;while (i++
This sets up a 'circular' array of size 'w' by using the 'mod' operator on the line number, resetting over and over.
At the end, start a window size back from the current line (NR) and print the saved away lines untill teh last line.
In the begin teh window size is declare (here w=3). You could use a command line argument, or a command line provid variable instead.

fwiw,

Hein.
Arunvijai_4
Honored Contributor
Solution

Re: Bug/Limitation in tail ??

GNU tail is part of GNU text file processing utilities. You can download from,

http://hpux.connect.org.uk/hppd/hpux/Gnu/textutils-2.1/

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
Daavid Turnbull
Frequent Advisor

Re: Bug/Limitation in tail ??

Dear All,

Your responses are much appreciated.

I ended up reading the file one line at a time and turfing the lines prior to the ones of interest. In the context of the script in question it is not an unreasonable way of doing it.

There is more than one way to do it ;-)
Behold the turtle for he makes not progress unless he pokes his head out.