Search code examples
bashawkgrepaix

how to extract word from ps -aux


when i execute command ps -ef | grep yypasswd I receive this output.

testacc 25124194 2512312620   0 08:00:53  pts/0  0:00 grep yypasswd

how can extract with command from this output word "yypasswd"


Solution

  • Since it's not clear what you're trying to do:

    If you expect the following output:

    yypasswd
    

    then do

    ps -ef | grep yypasswd | awk '{print $8}'
    

    if you want the following output:

    testacc 25124194 2512312620   0 08:00:53  pts/0  0:00
    

    then do

    ps -ef | grep yypasswd |  awk '{print $1, $2, $3, $4, $5, $6 ,$7}'
    

    hope that helps.