Operating System - HP-UX
1834628 Members
3198 Online
110069 Solutions
New Discussion

How do I do "tail -r" in HP-UX

 
Daniel Malcor
Occasional Advisor

How do I do "tail -r" in HP-UX


In some other (lesser) flavors of UNIX there is a very useful option for tail:

-r Reverse. Copies lines from the
specified starting point in the file
in reverse order.

This is VERY useful for viewing logfiles, but oddly missing from the tail in HP-UX. Any help?
Did you check the Logs?
7 REPLIES 7
Bill McNAMARA_1
Honored Contributor

Re: How do I do "tail -r" in HP-UX

according to the man you can't

http://devresource.hp.com/STK/man/11.00/tail_1.html

try less ?

Later,
Bill

It works for me (tm)
James R. Ferguson
Acclaimed Contributor

Re: How do I do "tail -r" in HP-UX

Hi Daniel:

You could hack it this way:

# tail ||awk '{array [NR]=$0};END{for (i=NR;i>0;i--) print array [i]}'

Regards!

...JRF...
Joseph C. Denman
Honored Contributor

Re: How do I do "tail -r" in HP-UX

how about this???

vi file.log
G "to go to bottom"
k "to scrollup"
:q! "to exit"


...jcd...
If I had only read the instructions first??
Daniel Malcor
Occasional Advisor

Re: How do I do "tail -r" in HP-UX

Oddly I already read the man page. vi is not a great option for a really large logfiles, and awk is always a bit awkward. There is a really simple perl solution:

perl -e 'print reverse <>' whatever.log

But again I'm worried that a really large log would be a problem.
Did you check the Logs?
James R. Ferguson
Acclaimed Contributor

Re: How do I do "tail -r" in HP-UX

Hi again, Daniel:

I agree that the perl solution is straightforward. Whether 'awk' is "awk"ward or not is philosophical. You didn't indicate any constraints when you posed your question. ;-)

Regards!

...JRF...
James R. Ferguson
Acclaimed Contributor

Re: How do I do "tail -r" in HP-UX

Hi again:

oops! That should be 'tail' piped to 'awk', as:

# tail |awk '{array [NR]=$0};END{for (i=NR;i>0;i--) print array [i]}'

...JRF...

Magdi KAMAL
Respected Contributor

Re: How do I do "tail -r" in HP-UX

Hi Daniel,

tail -f fileName

allow you to display on screen the last modifications on a specific file.

This is useful for monitoring log files.


Magdi