How to suppress the general information for top command

It's known as the "Summary Area" and i don't think there is a way at top initialization to disable those.

But while top is running, you can disable those by pressing l, t, m.

From man top:

 Summary-Area-defaults
  'l' - Load Avg/Uptime  On  (thus program name)
  't' - Task/Cpu states  On  (1+1 lines, see '1')
  'm' - Mem/Swap usage   On  (2 lines worth)
  '1' - Single Cpu       On  (thus 1 line if smp)

Came across this question today. I have a potential solution - create a top configuration file from inside top's interactive mode when the summary area is disabled. Since this file is also read at startup of top in batch mode, it will cause the summary area to be disabled in batch mode too.

Follow these steps to set it up..

  1. Launch top in interactive mode.

  2. Once inside interactive mode, disable the summary area by successively pressing 'l', 'm' and 't'.

  3. Press 'W' (upper case) to write your top configuration file (normally, ~/.toprc)

  4. Exit interactive mode.

Now when you run top in batch mode the summary area will not appear (!)

Taking it one step further...

If you only want this for certain situations and still want the summary area most of the time, you could use an alternate top configuration file. However, AFAIK, the way to get top to use an alternate config file is a bit funky. There are a couple of ways to do this. The approach I use is as follows:

  1. Create a soft-link to the top executable. This does not have to be done as root, as long as you have write access to the link's location...

    ln -s /usr/bin/top /home/myusername/bin/omgwtf
    
  2. Launch top by typing the name of the link ('omgwtf') rather than 'top'. You will be in normal top interactive mode, but when you save the configuration file it will write to ~/.omgwtfrc, leaving ~/.toprc alone.

  3. Disable the summary area and write the configuration file same as before (press 'l', 'm', 't' and 'W')

In the future, when you're ready to run top without summary info in batch mode, you'll have to invoke top via the link name you created. For example,

% omgwtf -usyslog -bn1
PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND
576 syslog    20   0  264496   8144   1352 S   0.0  0.1   0:03.66 rsyslogd
%

If you're running top in batch mode (-b -n1), just delete the header lines with sed:

top -b -n1 | sed 1,7d

That will remove the first 7 header lines that top outputs and returns only the processes.