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?
Best Answer
Pipe the output to fold to wrap the output at a specified width (defaultly 80):
-w
flag ofps
for wide output, and twice for unlimited output.fold -s
breaks at spaces.grep
command. I changedjava
to[j]ava
. This way thegrep
process will not match himself in theps
output.