4

I often used the following command,

ps -eo pid,cmd,pcpu,pmem --sort=-pcpu | head

But in the man page I saw the following to output modifiers,

   --lines n
          Set screen height.
   --rows n
          Set screen height.

As if these modifiers can limit row height then I don't have to use any kind of piping which gives me a bit comfort on writing scripts with python subprocess.

But I have no idea how can I use them. As I have already tried adding them at the end of the command.

Jeff Schaller
  • 67,283
  • 35
  • 116
  • 255
arif
  • 1,459

1 Answers1

9

The screen height doesn’t limit the total output, it determines how often the header is repeated (if requested):

ps -eo pid,cmd,pcpu,pmem --sort=-pcpu --lines=20 --header

will repeat the header every twenty lines (so you’ll get a header, nineteen lines of output, a header, etc.).

Stephen Kitt
  • 434,908