I need to extract the cmd from the output of ps
. I know that I can use the following to write only the PID using the ps
command:
ps ax | perl -nle 'print $1 if /^ *([0-9]+)/'
I am wondering if I could write only the command using something similar.
You can use
ps axhw -o cmd
h
disables headers.w
prevents the output from being truncated.-o cmd
identifies which fields to output.See also the c
output modifier.