I want to show all processes whose command line includes .*git.* using top.

I've considered the following command: top -p $(pgrep -d',' -f '.*git.*')

However, the above command has several caveats:

  • Only processes that exist while top is executed will be included in top's output (new .*git.*s are not included).
  • man top says that at most 20 processes may be specified using the -p flag, which may not be sufficient.

How can I show a dynamically top-like view of current .*git.* processes in the terminal?

  • 2
    Use htop instead with \git
    – muru
    Commented Oct 5, 2020 at 9:05
  • Thank you. Is htop a successor to top? Using htop \git still shows e.g. init in the output. Why?
    – Shuzheng
    Commented Oct 5, 2020 at 9:19
  • Where do you see in the man page that you can enter \git on the command line (just curious). I only see \ listed as an interactive command.
    – Shuzheng
    Commented Oct 5, 2020 at 9:25
  • 3
    You need to start htop, then type \git (or F4 followed by git). Commented Oct 5, 2020 at 9:26
  • @Shuzheng I didn't say it was a command line option. Are you specifically looking for command line options only?
    – muru
    Commented Oct 5, 2020 at 9:37

1 Answer 1


You can do this in top using “filtering in a window”: start top, then press O, and enter


This will filter processes, matching the COMMAND column and keeping only processes whose visible value in that column contains git.

When filtering on the COMMAND column, the filter applies to the currently-displayed value — either the name of the running program, or its full command line. This can be toggled by pressing c, or with the -c argument; the state is remembered between top invocations. Note that the filter applies only to the visible portion of the field; this can be a significant gotcha when filtering on the COMMAND column, if it isn’t fully visible or if it isn’t wide enough to include the relevant part of the command line. See the COMMAND field description in man top for details.

Filters are cumulative and can be cleared by pressing =. See section 5e of man top for details.

As far as I’m aware there’s no equivalent command-line option.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .