How to use `–lines` `–row` modifiers in `ps` command

ps

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.

Best Answer

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.).

Related Question