10

Consider the following command:

watch -d "ps -ef | grep java"

It gives following output:

kshitiz  11369 11285  0 Oct13 ?        00:06:02 /usr/lib/jvm/jdk1.7.0_40/jre/bin/java -Djava.awt.headless=true -Didea.version==14.1.2 -Xmx512m -Dfile.e

The output beyond -Dfile.e is truncated or flows off screen. How can I scroll to see the output or word wrap it?

Using fold without watch: enter image description here

Using fold with watch: enter image description here

0

2 Answers 2

9

Pipe the output to fold to wrap the output at a specified width (defaultly 80):

watch -d "ps -efww | grep '[j]ava' | fold -s"
  • Use the -w flag of ps for wide output, and twice for unlimited output.
  • fold -s breaks at spaces.
  • Also notice the grep command. I changed java to [j]ava. This way the grep process will not match himself in the ps output.
1
  • 1
    Though fold seems to work well by itself. With watch the output is still getting cut at -Dfile.e. Oct 14, 2015 at 8:07
3

In addition:

You can also try specifying the width; this will make full use of your screen width.

In my case, the following gives a perfectly formed output. Do customize the width parameter as per you monitor/terminal size:

watch -d "ps -ef --width 1000 | grep java | grep -v grep  "

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .