Operating System - HP-UX
1752579 Members
4340 Online
108788 Solutions
New Discussion юеВ

Re: Getting info from /usr/bin/top

 
SOLVED
Go to solution
Scott Frye_1
Super Advisor

Getting info from /usr/bin/top

HP-UX 11.0 and 11.i. I'm wanting to run `/usr/bin/top -n 1`. This should give me an output that only shows the highest process running. I want to pull just that line out and do some logic on in. Ideally what I thought I could do was...
top=/usr/bin/top -d 1 -n 1
topline= tail -n 1 "$top".

This is not working. Can anyone help me pull one line from a top output and do logic on it.

Thanks

Scott
3 REPLIES 3
Pete Randall
Outstanding Contributor
Solution

Re: Getting info from /usr/bin/top

Scott,

I believe you're going to need to route the top output through a file with the -f option and then use grep/sed/awk to capture the line you're interested in from that file.


Pete

Pete
Victor BERRIDGE
Honored Contributor

Re: Getting info from /usr/bin/top

Hi,
You cannot do it with top unless you redirect to a file and use it.This is what it would look like:
top -n1 -h -f toto;cat toto|tail -1

But this gives the same output:
UNIX95= ps -el -o pid,comm,sz|grep -i -v pid|sort -nr -k 3,3| head -1


All the best
Victor
Scott Frye_1
Super Advisor

Re: Getting info from /usr/bin/top

Thanks all. I missed the -f.

Scott