How to wrap output of watch command?
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 ofps
for wide output, and twice for unlimited output. fold -s
breaks at spaces.- Also notice the
grep
command. I changedjava
to[j]ava
. This way thegrep
process will not match himself in theps
output.
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 "