3

I'm trying to use the top command and exclude two users from showing in the iteration I'm sending to the textfile.

I have used the -u='!user' command-line option, but I can only exclude 1 user with it and am not able to use the option more than once.

I found a suggestion to use the command:

o!USER=user <enter> o!USER=user

but I'm fairly lost in how to implement it without getting an error.

1
  • Are you using top on Linux or on BSD or some other type of UNIX system? Implementations of top vary quite significantly, and they have different capabilities for filtering.
    – Kusalananda
    Oct 2, 2019 at 7:59

3 Answers 3

6

It works if you add one filter after another.

Run top and add a filter for the first user. Press o and enter

!USER=user1

, then press o and add the next filter

!USER=user2

and so forth...

2

If it were only one user, you could do

top -U '!user1'

The -U filters by real user id, whereas -u filters by effective user id.

I could not get multiple users to be filtered with this method.

1

If I understand you correctly, would this help?

top | grep -ve "user1" -e "user2"

You must log in to answer this question.

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