如何以非交互方式显示“top”的第一行?
How to show the first line of `top` non interatively?
top
on Mac 在屏幕顶部显示类似这样的内容。
Processes: 1104 total, 187 running, 917 sleeping, 2761 threads 19:41:00
我不想 运行 top
交互。有没有办法让 运行 top
非交互式,只将第一行打印到屏幕上?谢谢
例如,像这样:
top -b -n 1 |grep "Processes"
更多信息:
man top
试试这个:
$ top -l1 | head -n1
来自男人:
-l samples
Use logging mode and display samples samples, even if standard output is a terminal. 0 is treated as infinity. Rather than redisplaying, output is periodically printed in raw form. Note that the first sample displayed will have
an invalid %CPU displayed for each process, as it is calculated using the delta between samples.
top
on Mac 在屏幕顶部显示类似这样的内容。
Processes: 1104 total, 187 running, 917 sleeping, 2761 threads 19:41:00
我不想 运行 top
交互。有没有办法让 运行 top
非交互式,只将第一行打印到屏幕上?谢谢
例如,像这样:
top -b -n 1 |grep "Processes"
更多信息:
man top
试试这个:
$ top -l1 | head -n1
来自男人:
-l samples Use logging mode and display samples samples, even if standard output is a terminal. 0 is treated as infinity. Rather than redisplaying, output is periodically printed in raw form. Note that the first sample displayed will have an invalid %CPU displayed for each process, as it is calculated using the delta between samples.