How to wrap output of watch command?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP

up vote
7
down vote

favorite

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

share|improve this question

    up vote
    7
    down vote

    favorite

    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

    share|improve this question

      up vote
      7
      down vote

      favorite

      up vote
      7
      down vote

      favorite

      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

      share|improve this question

      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

      watch fold

      share|improve this question

      share|improve this question

      share|improve this question

      share|improve this question

      edited Dec 6 at 17:30

      Jeff Schaller

      37.9k1053123

      37.9k1053123

      asked Oct 14 ’15 at 6:59

      Kshitiz Sharma

      3,089104358

      3,089104358

          2 Answers
          2

          active

          oldest

          votes

          up vote
          6
          down vote

          accepted

          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.
          share|improve this answer

          • 1

            Though fold seems to work well by itself. With watch the output is still getting cut at -Dfile.e.
            – Kshitiz Sharma
            Oct 14 ’15 at 8:07

          up vote
          3
          down vote

          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  "
          

          share|improve this answer

            Your Answer

            StackExchange.ready(function() {
            var channelOptions = {
            tags: “”.split(” “),
            id: “106”
            };
            initTagRenderer(“”.split(” “), “”.split(” “), channelOptions);

            StackExchange.using(“externalEditor”, function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using(“snippets”, function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: ‘answer’,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: “”,
            imageUploader: {
            brandingHtml: “Powered by u003ca class=”icon-imgur-white” href=”https://imgur.com/”u003eu003c/au003e”,
            contentPolicyHtml: “User contributions licensed under u003ca href=”https://creativecommons.org/licenses/by-sa/3.0/”u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href=”https://stackoverflow.com/legal/content-policy”u003e(content policy)u003c/au003e”,
            allowUrls: true
            },
            onDemand: true,
            discardSelector: “.discard-answer”
            ,immediatelyShowMarkdownHelp:true
            });

            }
            });

            draft saved
            draft discarded

            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin(‘.new-post-login’, ‘https%3a%2f%2funix.stackexchange.com%2fquestions%2f236009%2fhow-to-wrap-output-of-watch-command%23new-answer’, ‘question_page’);
            }
            );

            Post as a guest

            Required, but never shown

            2 Answers
            2

            active

            oldest

            votes

            2 Answers
            2

            active

            oldest

            votes

            active

            oldest

            votes

            active

            oldest

            votes

            up vote
            6
            down vote

            accepted

            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.
            share|improve this answer

            • 1

              Though fold seems to work well by itself. With watch the output is still getting cut at -Dfile.e.
              – Kshitiz Sharma
              Oct 14 ’15 at 8:07

            up vote
            6
            down vote

            accepted

            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.
            share|improve this answer

            • 1

              Though fold seems to work well by itself. With watch the output is still getting cut at -Dfile.e.
              – Kshitiz Sharma
              Oct 14 ’15 at 8:07

            up vote
            6
            down vote

            accepted

            up vote
            6
            down vote

            accepted

            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.
            share|improve this answer

            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.
            share|improve this answer

            share|improve this answer

            share|improve this answer

            edited Oct 14 ’15 at 9:40

            answered Oct 14 ’15 at 7:07

            chaos

            35k773115

            35k773115

            • 1

              Though fold seems to work well by itself. With watch the output is still getting cut at -Dfile.e.
              – Kshitiz Sharma
              Oct 14 ’15 at 8:07

            • 1

              Though fold seems to work well by itself. With watch the output is still getting cut at -Dfile.e.
              – Kshitiz Sharma
              Oct 14 ’15 at 8:07

            1

            1

            Though fold seems to work well by itself. With watch the output is still getting cut at -Dfile.e.
            – Kshitiz Sharma
            Oct 14 ’15 at 8:07

            Though fold seems to work well by itself. With watch the output is still getting cut at -Dfile.e.
            – Kshitiz Sharma
            Oct 14 ’15 at 8:07

            up vote
            3
            down vote

            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  "
            

            share|improve this answer

              up vote
              3
              down vote

              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  "
              

              share|improve this answer

                up vote
                3
                down vote

                up vote
                3
                down vote

                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  "
                

                share|improve this answer

                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  "
                

                share|improve this answer

                share|improve this answer

                share|improve this answer

                edited Feb 11 ’16 at 6:58

                Will

                1,466722

                1,466722

                answered Feb 11 ’16 at 6:33

                Swapnil jaiswal

                313

                313

                    draft saved
                    draft discarded

                    Thanks for contributing an answer to Unix & Linux Stack Exchange!

                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid

                    • Asking for help, clarification, or responding to other answers.
                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.

                    Some of your past answers have not been well-received, and you’re in danger of being blocked from answering.

                    Please pay close attention to the following guidance:

                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid

                    • Asking for help, clarification, or responding to other answers.
                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.

                    draft saved

                    draft discarded

                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin(‘.new-post-login’, ‘https%3a%2f%2funix.stackexchange.com%2fquestions%2f236009%2fhow-to-wrap-output-of-watch-command%23new-answer’, ‘question_page’);
                    }
                    );

                    Post as a guest

                    Required, but never shown

                    Required, but never shown

                    Required, but never shown

                    Required, but never shown

                    Required, but never shown

                    Required, but never shown

                    Required, but never shown

                    Required, but never shown

                    Required, but never shown

                    Related Post

                    Leave a Reply

                    Your email address will not be published. Required fields are marked *