Have you ever used ps aux | grep ...
on GNU/Linux to grep for a running process? Have you
also used ps aux
to view the whole process list on your terminal? At first glance, the two
commands behave exactly the same, however ps
will truncate every line to fit within your
terminal's witdh of echo $COLUMNS
(see the man page ps(1)
). If you want wide output
(132 columns), specify another w
e.g. ps auxw
. If you want unlimited output, specify yet
another w
e.g. ps auxww
.
Now, if you execute ps aux | grep ...
and the string for which you are grep
ing is beyond
your terminal width, it shouln't have matched but it did. This is because ps
on GNU/Linux
automatically sets the unlimited width mode when the output is not a terminal for example when
piping to grep
or less
. This behaviour means you practically do not run into any problems.
On FreeBSD (I have only checked FreeBSD, there might be other implementations with this
behaviour), however, it will not switch to unlimited width mode automatically and you have
to manually specify two w
when you require untruncated output.