1848166 Members
6117 Online
104022 Solutions
New Discussion

Re: tail -n ?

 
SOLVED
Go to solution
Gary Yu
Super Advisor

tail -n ?

Hi all,

I'm trying to use "tail -1000 logfile" to get the last 1000 lines of a huge logfile. But I only got 310 lines, when I ran the same command on another file I only got 150 lines, is it a buffer size related issue or something else?

BTW, I don't want to use awk to get the result, because it takes long time to go through such huge file.

thanks,
Gary


8 REPLIES 8
Darrell Allen
Honored Contributor

Re: tail -n ?

Hi Gary,

From "man tail"...
"Tails relative to end-of-file are stored in a 20-Kbyte buffer, and thus are limited in length."

Search the forums for "tail limit" and you'll find a number of threads concerning this.

Darrell
"What, Me Worry?" - Alfred E. Neuman (Mad Magazine)
Martin Johnson
Honored Contributor

Re: tail -n ?

"tail -1000 logfile" is obsolete. Try "tail -n 1000 logfile".

HTH
Marty
Clemens van Everdingen
Honored Contributor

Re: tail -n ?

Hi,

Since the answer is already there I can only add a hint.

Why not rotating the log file so you keep it small enough to search through.

See the example scripts at

http://www.introcomp.co.uk/examples/index.html

C.
The computer is a great invention, there are as many mistakes as ever, but they are nobody's fault !
Darrell Allen
Honored Contributor
Solution

Re: tail -n ?

Although it's still best for you to search the forums, here's one I found:
http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x6cc8d06ed8c8d4118fef0090279cd0f9,00.html

Darrell
"What, Me Worry?" - Alfred E. Neuman (Mad Magazine)
Gary Yu
Super Advisor

Re: tail -n ?

thanks guys for the replies, I'm sure now that it's a buffer related problem. By searching the archived threads I found sed -n is a good workaround, it seems to be faster than 'awk NR > ??? ' But why HP won't upgrade the tail command to solve the 20k buffer issue?
Helen French
Honored Contributor

Re: tail -n ?

This issue has been solved on 11.11 version with patch - PHCO_24707. Check this document (TKB# DMLCNCKBRC00008118):
http://www1.itrc.hp.com/service/cki/docDisplay.do?docLocale=en_US&docId=200000063218431
Life is a promise, fulfill it!
Helen French
Honored Contributor

Re: tail -n ?

This is the patch description:
http://www1.itrc.hp.com/service/cki/patchDocDisplay.do?patchId=PHCO_24707
Life is a promise, fulfill it!
paul fritzsche
Advisor

Re: tail -n ?


more | tail -1000

thats how you do it! =)

Regards Paul