When using ps with a user-defined format, how do I get a column with unlimited width?

Joshua Garcia asked:

I’m using ps with the user-defined format as shown below:

$ ps ax -o pid,args,psr,pcpu | grep python
2236 /usr/bin/python2.7 -u /home   2  0.0
2452 /usr/bin/python /usr/lib/un   2  0.0
2480 /usr/bin/python /usr/lib/ub   0  0.7
2501 /usr/bin/python /usr/lib/un   2  0.0
4129 /usr/bin/python /usr/bin/up   0  0.1
4792 grep --color=auto python      0  0.0
20665 /usr/bin/python /usr/lib/sy   0  0.0
27022 python                        0  0.0

I specifically want to have an unlimited width for args. I know that I can provided a set width like this:

$ ps axww -o pid,args:100,psr,pcpu | grep python
2236 /usr/bin/python2.7 -u /home/joshua/Applications/eclipse-classic-4.2/plugins/org.python.pydev_2.7.3.2   2  0.0
2452 /usr/bin/python /usr/lib/unity-lens-video/unity-lens-video                                             2  0.0
2480 /usr/bin/python /usr/lib/ubuntuone-client/ubuntuone-syncdaemon                                         3  0.7
2501 /usr/bin/python /usr/lib/unity-scope-video-remote/unity-scope-video-remote                             2  0.0
4129 /usr/bin/python /usr/bin/update-manager --no-focus-on-map                                              2  0.1
4905 grep --color=auto python                                                                               2  0.0

20665 /usr/bin/python /usr/lib/system-service/system-service-d 0 0.0
27022 python 0 0.0

I’ve tried using the ww option for unlimited width, but it does not work. Here’s the command I used when trying ww:

$ ps axww -o pid,args,psr,pcpu | grep python

My answer:


Make the variable-length column, args, the last column.

$ ps axww -o pid,psr,pcpu,args | grep python

View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.