Search code examples
linuxunixps

How to get output to show only CMD with ps -u UserName


If I do the command in Linux:

ps -u UserName

Then I get a list of things in format of:

PID TTY          TIME CMD

How can I get output to show only CMD(filenames)?


Solution

  • awk work like charm:

    ps -u username | awk '{print $4}'
    

    awk by default uses space delimiter , so you will get four fields that is PID is $1, TTY is $2, TIME is $3 and CMD is $4, so in my code i have printed only $4 to give you CMD fields.