sudo ps o gpid,comm reports something like 3029 bash but the command has parameters --arbitrary -other -searchword is there a way to display these arguments?

  • Whats wrong with ps -ef ? – heemayl Jun 30 '15 at 19:25
  • Yeah the point is actually just to get the pgids but grep on the arguments to find the right ones. So with an awk command ps -ef should would the same. Ill ask more specific questions moving forward – channon Jun 30 '15 at 19:30
  • In that case the easier would be pgrep -a bash ..check it.. – heemayl Jun 30 '15 at 19:33

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

The following command:

sudo ps o gpid,comm,args

will print:

3029 bash       bash --arbitrary -other -searchword

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.