Using bash ps and cut together Using bash ps and cut together bash bash

Using bash ps and cut together


ps is printing out space separators, but cut without -d uses the tab character. The tr -s squeezes the spaces together to get more of the separation that you want, but remember that there is the initial set of spaces (squeezed to one) hence why you need to add 1 to each field. Also, there are spaces in the commands for each word. This should work:

ps -L u n | tr -s " " | cut -d " " -f 2,3,14-


Is there any particular reason for using cut?

I guess this will do what you want:

ps -eopid,uid,cmd


You can use awk to clean up your command, like so:

ps -L u n | awk '{ print $1,$2,$13 }'