Ps: format (separator and width)

ps

I'd like to specify the column-separator

ps -o "%a|%p"        # separator |

and the column-width

ps -o cmd:50,pid     # width 50 for cmd

in one command.
Is this possible??

It is not about the column-width but I'd like to have the full length command even if it is not the last column.

Best Answer

The -o command is additive, so just do multiple of those:

ps -a -o "cmd:50 " -o "|%p"
CMD                                               |  PID
/usr/lib/gnome-session/gnome-session-binary --auto| 4158

The problem is that you'll get some whitespace around the PID as its right-justified. You can see the 4158 above has a space after the pipe.

Related Question