Operating System - HP-UX
1834593 Members
4408 Online
110069 Solutions
New Discussion

Re: Trim application log files on HP-UX 11.0

 
Raj Kumar Gulati
Occasional Contributor

Trim application log files on HP-UX 11.0

I want to trim application log file in /var/adm/syslog/app.log .

But tail -10000 /var/adm/syslog/app.log > /tmp/app.log.trim does not work as tail -10000 takes only few number of last lines,not last 10000 lines from log file.

I am using HP-UX 11.0.It seems only buffer of 20K is reserved for this tail program.
3 REPLIES 3
Sanjay Kumar Suri
Honored Contributor

Re: Trim application log files on HP-UX 11.0

Use -n to specify the number of lines.

tail -n 10000 /var/adm/syslog/app.log > /tmp/app.log.trim

sks
A rigid mind is very sure, but often wrong. A flexible mind is generally unsure, but often right.
Pete Randall
Outstanding Contributor

Re: Trim application log files on HP-UX 11.0

From the man page:

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


Pete

Pete
Steve Steel
Honored Contributor

Re: Trim application log files on HP-UX 11.0

Hi

reverse it

make this a script with file as parameter 1 and lines as parameter 2



file=$1
typeset lines=$2
typeset -i x=$(cat $file|wc -l)
typeset -i z=$x-$lines+1
tail -n +$z $file


Steve Steel


If you want truly to understand something, try to change it. (Kurt Lewin)