3

I've been scrounging around the man page trying to understand ps better. Is there a combination of flags that causes ps to return all of the processes for my user that aren't attached to a terminal? The -t - and -u steve filters seem to combine as an OR, returning all non-terminal processes for all users plus all processes for the given user:

ps -t - -f -u steve

But I want them to function as an AND, returning only non-terminal processes for a single user, preferably automatically using the current user.

Is there a way to do this with just ps alone?

xdhmoore
  • 145

1 Answers1

1

I'm afraid the answer is a plain no, it is not possible to combine them with a logical AND with ps alone.

At the end of OPTIONS section of the ps POSIX specification (bold+italics are my addition):

With the exception of -f, -l, -n namelist, and -o format, all of the options shown are used to select processes. If any are specified, the default list shall be ignored and ps shall select the processes represented by the inclusive OR of all the selection-criteria options.

Also, no switch is to be found that turns that OR into an AND.

Quasímodo
  • 18,865
  • 4
  • 36
  • 73
  • I suppose that if they had to pick either OR or AND, it probably makes the most sense to use OR and then you can use grep or whatever to apply AND operations. – xdhmoore Jul 05 '20 at 17:07