0

I start 2 processes in the background: xeyes and xclock -update 1. When I run this commane: ps T o pid,tty,time,args,state (this for to output state) it lists:

PID TT           TIME COMMAND                     S
   5875 pts/0    00:00:00 bash                        S
   5881 pts/0    00:00:01 xeyes                       S
   5921 pts/0    00:00:00 xclock -update 1            S
   6141 pts/0    00:00:00 sleep 100                   T
   6340 pts/0    00:00:00 ps T o pid,tty,time,args,st R

How can I print out the state for only one process? For instance if I want to print the state of only the xeyes process.

Andy Dalton
  • 13,993

1 Answers1

2

The ps command offers several options to enable you to select what is included in the output. I suggest you take a look at man ps to see the options that it exposes.

If you want to list processes by the command name, you can use the -C option. For example:

$ ps -C xeyes ... other options ...

You can also select a process by its process ID (if you know it already) using the -p option. For example:

$ ps -p 5881 ... other options ...
Andy Dalton
  • 13,993