私はそれを使用し、top -b -n 2 | awk '{if ($9 != 0.0) print $0,sed -n '8,20p'}'>>text.txt
出力は次のようになります。
top - 16:24:42 up 3:49, 3 users, load average: 0.23, 0.29, 0.31
Threads: 503 total, 2 running, 501 sleeping, 0 stopped, 0 zombie
%Cpu(s): 9.7 us, 1.6 sy, 0.0 ni, 88.5 id, 0.2 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem: 3938668 total, 2148708 used, 1789960 free, 133524 buffers
KiB Swap: 3903484 total, 0 used, 3903484 free. 822904 cached Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1054 root 20 0 258664 3524 2692 S 0.5 0.1 0:00.00 rsyslogd
1086 root 20 0 258664 3524 2692 S 0.4 0.1 0:00.03 in:imuxsock
1087 root 20 0 258664 3524 2692 S 0.3 0.1 0:00.00 in:imklog
1090 root 20 0 258664 3524 2692 S 0.3 0.1 0:00.05 rs:main Q:Reg
2452 fpiat 20 0 25292 7520 3580 S 0.3 0.2 0:00.69 bash
2495 fpiat 20 0 25088 6988 3256 S 0.3 0.2 0:00.05 bash
top - 16:24:42 up 3:49, 3 users, load average: 0.23, 0.29, 0.31
Threads: 503 total, 2 running, 501 sleeping, 0 stopped, 0 zombie
%Cpu(s): 9.7 us, 1.6 sy, 0.0 ni, 88.5 id, 0.2 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem: 3938668 total, 2148708 used, 1789960 free, 133524 buffers
KiB Swap: 3903484 total, 0 used, 3903484 free. 822904 cached Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1054 root 20 0 258664 3524 2692 S 0.5 0.1 0:00.00 rsyslogd
1086 root 20 0 258664 3524 2692 S 0.4 0.1 0:00.03 in:imuxsock
1087 root 20 0 258664 3524 2692 S 0.3 0.1 0:00.00 in:imklog
1090 root 20 0 258664 3524 2692 S 0.3 0.1 0:00.05 rs:main Q:Reg
2452 fpiat 20 0 25292 7520 3580 S 0.3 0.2 0:00.69 bash
2495 fpiat 20 0 25088 6988 3256 S 0.3 0.2 0:00.05 bash
次のような出力を取得したいです(ヘッダーが印刷されないことを意味します)。
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1054 root 20 0 258664 3524 2692 S 0.5 0.1 0:00.00 rsyslogd
1086 root 20 0 258664 3524 2692 S 0.4 0.1 0:00.03 in:imuxsock
1087 root 20 0 258664 3524 2692 S 0.3 0.1 0:00.00 in:imklog
1090 root 20 0 258664 3524 2692 S 0.3 0.1 0:00.05 rs:main Q:Reg
2452 fpiat 20 0 25292 7520 3580 S 0.3 0.2 0:00.69 bash
2495 fpiat 20 0 25088 6988 3256 S 0.3 0.2 0:00.05 bash
1054 root 20 0 258664 3524 2692 S 0.5 0.1 0:00.00 rsyslogd
1086 root 20 0 258664 3524 2692 S 0.4 0.1 0:00.03 in:imuxsock
1087 root 20 0 258664 3524 2692 S 0.3 0.1 0:00.00 in:imklog
1090 root 20 0 258664 3524 2692 S 0.3 0.1 0:00.05 rs:main Q:Reg
2452 fpiat 20 0 25292 7520 3580 S 0.3 0.2 0:00.69 bash
2495 fpiat 20 0 25088 6988 3256 S 0.3 0.2 0:00.05 bash
誰でも解決策を提案できますか?
ベストアンサー1
注文する:top -b -n1| sed -n '/PID/,$p'
出力
ux_example ~]# top -b -n1| sed -n '/PID/,$p'
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
7 root RT 0 0 0 0 S 1.7 0.0 0:01.04 migration/1
1 root 20 0 19356 1564 1252 S 0.0 0.1 0:07.96 init
2 root 20 0 0 0 0 S 0.0 0.0 0:00.07 kthreadd
3 root RT 0 0 0 0 S 0.0 0.0 0:03.46 migration/0
4 root 20 0 0 0 0 S 0.0 0.0 0:01.84 ksoftirqd/0
5 root RT 0 0 0 0 S 0.0 0.0 0:00.00 migration/0
6 root RT 0 0 0 0 S 0.0 0.0 1:58.23 watchdog/0
8 root RT 0 0 0 0 S 0.0 0.0 0:00.00 migration/1
9 root 20 0 0 0 0 S 0.0 0.0 0:02.87 ksoftirqd/1
10 root RT 0 0 0 0 S 0.0 0.0 2:10.65 watchdog/1
11 root RT 0 0 0 0 S 0.0 0.0 0:02.42 migration/2
12 root RT 0 0 0 0 S 0.0 0.0 0:00.00 migration/2
13 root 20 0 0 0 0 S 0.0 0.0 0:01.27 ksoftirqd/2
14 root RT 0 0 0 0 S 0.0 0.0 1:55.75 watchdog/2
15 root RT 0 0 0 0 S 0.0 0.0 0:01.03 migration/3
16 root RT 0 0 0 0 S 0.0 0.0 0:00.00 migration/3
17 root 20 0 0 0 0 S 0.0 0.0 0:00.95 ksoftirqd/3
18 root RT 0 0 0 0 S 0.0 0.0 1:58.07 watchdog/3
19 root 20 0 0 0 0 S 0.0 0.0 0:14.40 events/0
20 root 20 0 0 0 0 S 0.0 0.0 3:52.96 events/1
21 root 20 0 0 0 0 S 0.0 0.0 0:16.77 events/2
22 root 20 0 0 0 0 S 0.0 0.0 1:34.48 events/3
23 root 20 0 0 0 0 S 0.0 0.0 0:00.00 cgroup
24 root 20 0 0 0 0 S 0.0 0.0 0:00.01 khelper
25 root 20 0 0 0 0 S 0.0 0.0 0:00.00 netns
26 root 20 0 0 0 0 S 0.0 0.0 0:00.00 async/mgr
27 root 20 0 0 0 0 S 0.0 0.0 0:00.00 pm
28 root 20 0 0 0 0 S 0.0 0.0 0:07.44 sync_supers
29 root 20 0 0 0 0 S 0.0 0.0 0:03.43 bdi-default
30 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kintegrityd/0
31 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kintegrityd/1
32 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kintegrityd/2
33 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kintegrityd/3
34 root 20 0 0 0 0 S 0.0 0.0 0:02.02 kblockd/0
35 root 20 0 0 0 0 S 0.0 0.0 0:01.02 kblockd/1
36 root 20 0 0 0 0 S 0.0 0.0 0:07.83 kblockd/2
37 root 20 0 0 0 0 S 0.0 0.0 0:22.51 kblockd/3
38 root 20 0 0 0 0 S 0.0 0.0 0: