show only certain rows with top

0

Using Geektool I want to output some of the stats that top spits out on my desktop, but not all of them. Rather than calling top | grep "Line_I_want_to_spit_out" for each different line I want it to show(resulting in 5-6 separate calls to top), is it possible to just call top once and select the lines I want it to show? (ex. show Processes, CPU usage, PhysMem, and the top 10 processes ordered by cpu)

flapjacks

Posted 2013-02-13T20:29:20.937

Reputation: 117

Which lines do you want to display? – Dennis – 2013-02-13T20:55:55.123

Processes, CPU usage, PhysMem, Networks and 10 processes ordered by cpu usage – flapjacks – 2013-02-13T21:15:59.740

On the command line, top | grep PATTERN keeps refreshing, rather than just producing a single static output. Is this what you want? (I'm not familiar with Geektool.) – Dennis – 2013-02-13T21:22:13.080

Answers

1

If you're not averse to using grep, you can do something like top | grep -E "Line1|Line2|etc"

BowlesCR

Posted 2013-02-13T20:29:20.937

Reputation: 2 607

That definitely works for the information on top. Do you know if it's possible to also have it show the top 10 processes ordered by cpu usage (top -n10 -o-CPU -stats cpu,command)? Or would that have to be a second call to top? – flapjacks – 2013-02-13T21:18:29.740

-1

Use:

ps -arcwwwxo "command %cpu %mem" | grep -v grep | head -9

rob

Posted 2013-02-13T20:29:20.937

Reputation: 1

1While this might answer the question it might be good to break out and explain the separate parts to educate as well as answer the question. – Mokubai – 2016-12-13T07:22:07.247