How to show only processes *not* matching a filter

filterhtop

I'm using htop to interactively monitor my processes.

However, sometimes a few processes get "in the way" and I would like to filter them out.

Unfortunately, it seems that htop's built in filter (e.g. F4) only allows me to define a positive filter (only matches will be shown), and not negative filters (all but matches are shown).

Finally, I haven't found any documentation about the actual syntax of the search-string (regexes don't seem to work).

Best Answer

I don't know if it's doable with htop but if using another top implementation is an option, with the top implementation in procps on Linux (generally the default implementation there), from within top, you can

  1. enter o (or O for case sensitive matching)
  2. enter !COMMAND=notwanted (or !USER=unwanted)

to filter out the processes whose name (or command line after pressing c) contains notwanted (or whose username contains unwanted). Enter = to remove all the filters.

You can filter on any of the fields you want, but only when they are displayed. For instance, to exclude kernel tasks, you can ask for the CODE column to be displayed (with f) and then filter on CODE>0 (with o).

Note that the default interface of that top implementation may look cruder than that of htop, but it has actually quite a lot more features (and you can configure it with colour and extra information if need be).

Related Question