From: underh20.scubadiving on
Dear Sir/Madam

We have an on-going program to run "top" command at certain time and
generates the report below. We need to extract the 4 lines above the
heading "PID USERNAME LWP......" to another file. Could we use "tail"
command to do that ? If yes, what option should we use. If you have
better suggestion, please let me know also.

Thanks, Bill


:
:
:
:
:
:
:
load averages: 0.21, 0.12, 0.12
13:43:19
156 processes: 155 sleeping, 1 on
cpu
CPU states: 98.6% idle, 0.2% user, 0.5% kernel, 0.7% iowait, 0.0%
swap
Memory: 12G real, 7511M free, 2652M swap in use, 11G swap
free

PID USERNAME LWP PRI NICE SIZE RES STATE TIME CPU COMMAND
828 root 7 58 0 12M 8488K sleep 221:59 0.22%
BESClient
2649 root 62 0 10 226M 154M sleep 296:30 0.19% java
9547 root 1 58 0 7136K 3280K sleep 0:00 0.15% sshd2
9575 izzy 1 55 0 2896K 1840K cpu/9 0:00 0.06% top
18597 poppy 20 58 0 23M 10M sleep 18:49 0.05% opmn
18698 poppy 17 58 0 129M 58M sleep 109:08 0.05% emagent
9544 l1ocwdv 1 58 0 950M 863M sleep 0:00 0.03% oracle
9550 izzy 1 40 0 1928K 1344K sleep 0:00 0.02% ksh
13375 daisy 1 58 0 952M 870M sleep 20:39 0.02% oracle
2406 root 9 58 0 7424K 5080K sleep 2:47 0.02%
sisidsdaemon
13379 daisy 1 58 0 950M 855M sleep 12:17 0.01% oracle
18607 dairy 30 28 10 309M 140M sleep 8:55 0.01% java
13369 daisy 15 58 0 958M 869M sleep 9:18 0.01% oracle
650 root 8 40 0 3416K 2424K sleep 0:40 0.01% nscd
13505 izzy 1 58 0 515M 450M sleep 9:09 0.01%
oracle <---- end of report
From: Sam N on
underh20.scubadiving(a)gmail.com wrote:
> Dear Sir/Madam
>
> We have an on-going program to run "top" command at certain time and
> generates the report below. We need to extract the 4 lines above the
> heading "PID USERNAME LWP......" to another file. Could we use "tail"
> command to do that ? If yes, what option should we use. If you have
> better suggestion, please let me know also.
>
> Thanks, Bill


Hi Bill

top | head -4 > output

cheers

Sam

From: Bill Marcum on
["Followup-To:" header set to comp.unix.questions.] On 2008-04-22,
underh20.scubadiving(a)gmail.com <underh20.scubadiving(a)gmail.com> wrote:
>
>
> Dear Sir/Madam
>
> We have an on-going program to run "top" command at certain time and
> generates the report below. We need to extract the 4 lines above the
> heading "PID USERNAME LWP......" to another file. Could we use "tail"
> command to do that ? If yes, what option should we use. If you have
> better suggestion, please let me know also.
>
> Thanks, Bill
>
You use tail to get the last n lines of a file, or everything from the
n'th line to the end. You use head to get lines at the beginning of the
file. For lines in the middle you can pipe head and tail together, or
use a more versatile tool such as sed, awk or perl.

From: usenetpersongerryt on
On Apr 22, 10:58 am, underh20.scubadiv...(a)gmail.com wrote:
>
> We have an on-going program to run "top" command at certain time and
> generates the report below. We need to extract the 4 lines above the
> heading "PID USERNAME LWP......" to another file. Could we use "tail"
> command to do that ? If yes, what option should we use. If you have
> better suggestion, please let me know also.
>
> load averages: 0.21, 0.12, 0.12 13:43:19
> 156 processes: 155 sleeping, 1 on cpu
> CPU states: 98.6% idle, 0.2% user, 0.5% kernel, 0.7% iowait, 0.0% swap
> Memory: 12G real, 7511M free, 2652M swap in use, 11G swap free

IF this is a Solaris question I suggest using prstat over top unless
there is something
specific that top does that prstat does not...