ps Output is Truncated when Piped to grep On Oracle Solaris
You may have noticed running ps from the command line produces output that you later can not filter for using grep on Oracle Solaris. You can get a visual understanding of what grep is seeing by piping the output into less:
$ ps aux
USER PID %CPU %MEM SZ RSS TT S START TIME COMMAND
user 5403 5.7 9.463597966305772 ? S 16:42:27 48:30 /opt/VirtualBox/amd64/VBoxHeadless --comment mail --startvm
user 1313 2.8 3.322088802159016 ? S Nov 15 696:52 /opt/VirtualBox/amd64/VBoxHeadless --comment nextcloud --startvm
user 3973 1.3 1.611256801074444 ? S 23:01:16 59:10 /opt/VirtualBox/amd64/VBoxHeadless --comment piranha1 --startvm
user 3974 0.6 1.711521601106504 ? S 23:01:19 60:23 /opt/VirtualBox/amd64/VBoxHeadless --comment piranha2 --startvm
user 997 0.5 0.110100053588 ? S Nov 15 31:50 /opt/VirtualBox/amd64/VBoxSVC --auto-shutdown
user 5404 0.4 0.4257364227628 ? S 16:42:54 1:38 /opt/VirtualBox/amd64/VirtualBoxVM --comment mail --startvm
user 987 0.2 0.13010412384 ? S Nov 15 8:32 /opt/VirtualBox/amd64/VBoxXPCOMIPCD
root 3 0.2 0.0 0 0 ? S Nov 15 43:57 fsflush
root 5 0.2 0.0 0 0 ? S Nov 15 31:34 zpool-rpool
~ vs ~
$ ps aux | less
USER PID %CPU %MEM SZ RSS TT S START TIME COMMAND
user 5403 7.8 9.463597966305772 ? O 16:42:27 48:03 /opt/VirtualBox/am
user 1313 3.1 3.322088802159016 ? S Nov 15 696:41 /opt/VirtualBox/am
user 3973 0.6 1.611236321072396 ? S 23:01:16 59:06 /opt/VirtualBox/am
user 3974 0.5 1.711521601106504 ? S 23:01:19 60:21 /opt/VirtualBox/am
user 997 0.5 0.110100053588 ? S Nov 15 31:48 /opt/VirtualBox/am
user 5404 0.4 0.4257364227628 ? S 16:42:54 1:36 /opt/VirtualBox/am
user 987 0.2 0.13010412384 ? S Nov 15 8:31 /opt/VirtualBox/am
root 3 0.2 0.0 0 0 ? S Nov 15 43:56 fsflush
root 5 0.2 0.0 0 0 ? S Nov 15 31:33 zpool-rpool
...
Typical Linux versions of ps will detect whether they are outputting to a terminal and truncate accordingly or if they are being piped and will automatically output in "arbitrarily wide" format. We can get the same functionality by adding the ww flag, as in:
ps auxww
From the man page for ps:
w Uses a wide output format, that is, 132 columns rather than 80. If the option letter is repeated, that is, -ww, this option uses arbi- trarily wide output. This information is used to decide how much of long commands to print. Note - The wide output option can be viewed only by a superuser or the user who owns the process.
Comments
There are no comments for this item.