How to find and print arguments of a command in ps?
Rather than formatting the output of ps
and then using grep
, you can simply use pgrep
with -a
option:
pgrep -a bash
This will show the command name (bash
) along with its arguments (if any).
From man pgrep
:
-a, --list-full
List the full command line as well as the process ID.
Actually, you don't have to grep anything when using ps
(at least the procps-ng implementation typically found on GNU/Linux systems, or the HP-UX ps
), run this:
ps -o args= -C bash
If the list of arguments is very long, you may throw in a couple of -w
options (though not on HP-UX):
ps -wwo args= -C bash