top
on Mac shows something like this on the top of the screen.
Processes: 1104 total, 187 running, 917 sleeping, 2761 threads 19:41:00
I don't want to run top
interactively. Is there a way to run top
noninteractive and just print this top line to the screen? Thanks.
Try this:
$ top -l1 | head -n1
From the man:
-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.