Force wrapping the long output lines that aren't so in terminal












1















Usually when the long lines are output in terminal/console/xterm, they will be wrapped automatically. However, there are cases that are not. ps is one of such cases -- it cuts the output right at the windows width.



 ps ax | grep [d]nsmasq
4459 ? S 0:03 /usr/sbin/dnsmasq -x /run/dnsmasq/dnsmasq.pid -u dnsm


For the dnsmasq, even I maximize my xterm, the output is still being cut.



I've tried,



 $ ps ax | fold | grep [d]nsmasq
4459 ? S 0:03 /usr/sbin/dnsmasq -x /run/dnsmasq/dnsmasq.pid -u dnsm

$ ps ax | grep [d]nsmasq | fold
4459 ? S 0:03 /usr/sbin/dnsmasq -x /run/dnsmasq/dnsmasq.pid -u dnsm

$ ps ax | grep [d]nsmasq | fold --spaces
4459 ? S 0:03 /usr/sbin/dnsmasq -x /run/dnsmasq/dnsmasq.pid -u dnsm


Such cutting make ps seems like not writing to standard output, but its responding to grep proves otherwise. But how come the fold not working then?



How to wrapping such long lines to show everything instead of cutting to the windows' width?










share|improve this question



























    1















    Usually when the long lines are output in terminal/console/xterm, they will be wrapped automatically. However, there are cases that are not. ps is one of such cases -- it cuts the output right at the windows width.



     ps ax | grep [d]nsmasq
    4459 ? S 0:03 /usr/sbin/dnsmasq -x /run/dnsmasq/dnsmasq.pid -u dnsm


    For the dnsmasq, even I maximize my xterm, the output is still being cut.



    I've tried,



     $ ps ax | fold | grep [d]nsmasq
    4459 ? S 0:03 /usr/sbin/dnsmasq -x /run/dnsmasq/dnsmasq.pid -u dnsm

    $ ps ax | grep [d]nsmasq | fold
    4459 ? S 0:03 /usr/sbin/dnsmasq -x /run/dnsmasq/dnsmasq.pid -u dnsm

    $ ps ax | grep [d]nsmasq | fold --spaces
    4459 ? S 0:03 /usr/sbin/dnsmasq -x /run/dnsmasq/dnsmasq.pid -u dnsm


    Such cutting make ps seems like not writing to standard output, but its responding to grep proves otherwise. But how come the fold not working then?



    How to wrapping such long lines to show everything instead of cutting to the windows' width?










    share|improve this question

























      1












      1








      1








      Usually when the long lines are output in terminal/console/xterm, they will be wrapped automatically. However, there are cases that are not. ps is one of such cases -- it cuts the output right at the windows width.



       ps ax | grep [d]nsmasq
      4459 ? S 0:03 /usr/sbin/dnsmasq -x /run/dnsmasq/dnsmasq.pid -u dnsm


      For the dnsmasq, even I maximize my xterm, the output is still being cut.



      I've tried,



       $ ps ax | fold | grep [d]nsmasq
      4459 ? S 0:03 /usr/sbin/dnsmasq -x /run/dnsmasq/dnsmasq.pid -u dnsm

      $ ps ax | grep [d]nsmasq | fold
      4459 ? S 0:03 /usr/sbin/dnsmasq -x /run/dnsmasq/dnsmasq.pid -u dnsm

      $ ps ax | grep [d]nsmasq | fold --spaces
      4459 ? S 0:03 /usr/sbin/dnsmasq -x /run/dnsmasq/dnsmasq.pid -u dnsm


      Such cutting make ps seems like not writing to standard output, but its responding to grep proves otherwise. But how come the fold not working then?



      How to wrapping such long lines to show everything instead of cutting to the windows' width?










      share|improve this question














      Usually when the long lines are output in terminal/console/xterm, they will be wrapped automatically. However, there are cases that are not. ps is one of such cases -- it cuts the output right at the windows width.



       ps ax | grep [d]nsmasq
      4459 ? S 0:03 /usr/sbin/dnsmasq -x /run/dnsmasq/dnsmasq.pid -u dnsm


      For the dnsmasq, even I maximize my xterm, the output is still being cut.



      I've tried,



       $ ps ax | fold | grep [d]nsmasq
      4459 ? S 0:03 /usr/sbin/dnsmasq -x /run/dnsmasq/dnsmasq.pid -u dnsm

      $ ps ax | grep [d]nsmasq | fold
      4459 ? S 0:03 /usr/sbin/dnsmasq -x /run/dnsmasq/dnsmasq.pid -u dnsm

      $ ps ax | grep [d]nsmasq | fold --spaces
      4459 ? S 0:03 /usr/sbin/dnsmasq -x /run/dnsmasq/dnsmasq.pid -u dnsm


      Such cutting make ps seems like not writing to standard output, but its responding to grep proves otherwise. But how come the fold not working then?



      How to wrapping such long lines to show everything instead of cutting to the windows' width?







      linux ubuntu command-line terminal






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Feb 23 at 14:23









      xptxpt

      3,216145693




      3,216145693






















          3 Answers
          3






          active

          oldest

          votes


















          1














          Duh, found the answer soon after I asked it.



          COLUMNS=500 ps ax | grep [d]nsmasq | fold


          The same trick works for dpkg as well.






          share|improve this answer































            0














            Check the man page. Compare these 3 outputs:



            ps ax
            ps axw
            ps axww





            share|improve this answer































              0














              ps checks whether its output goes to a terminal, and if so, queries the terminal's width. Then ps itself truncates each line according to that width. It's not the terminal chopping them, it doesn't even receive this data.






              share|improve this answer























                Your Answer








                StackExchange.ready(function() {
                var channelOptions = {
                tags: "".split(" "),
                id: "3"
                };
                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',
                autoActivateHeartbeat: false,
                convertImagesToLinks: true,
                noModals: true,
                showLowRepImageUploadWarning: true,
                reputationToPostImages: 10,
                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%2fsuperuser.com%2fquestions%2f1408774%2fforce-wrapping-the-long-output-lines-that-arent-so-in-terminal%23new-answer', 'question_page');
                }
                );

                Post as a guest















                Required, but never shown

























                3 Answers
                3






                active

                oldest

                votes








                3 Answers
                3






                active

                oldest

                votes









                active

                oldest

                votes






                active

                oldest

                votes









                1














                Duh, found the answer soon after I asked it.



                COLUMNS=500 ps ax | grep [d]nsmasq | fold


                The same trick works for dpkg as well.






                share|improve this answer




























                  1














                  Duh, found the answer soon after I asked it.



                  COLUMNS=500 ps ax | grep [d]nsmasq | fold


                  The same trick works for dpkg as well.






                  share|improve this answer


























                    1












                    1








                    1







                    Duh, found the answer soon after I asked it.



                    COLUMNS=500 ps ax | grep [d]nsmasq | fold


                    The same trick works for dpkg as well.






                    share|improve this answer













                    Duh, found the answer soon after I asked it.



                    COLUMNS=500 ps ax | grep [d]nsmasq | fold


                    The same trick works for dpkg as well.







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Feb 23 at 14:27









                    xptxpt

                    3,216145693




                    3,216145693

























                        0














                        Check the man page. Compare these 3 outputs:



                        ps ax
                        ps axw
                        ps axww





                        share|improve this answer




























                          0














                          Check the man page. Compare these 3 outputs:



                          ps ax
                          ps axw
                          ps axww





                          share|improve this answer


























                            0












                            0








                            0







                            Check the man page. Compare these 3 outputs:



                            ps ax
                            ps axw
                            ps axww





                            share|improve this answer













                            Check the man page. Compare these 3 outputs:



                            ps ax
                            ps axw
                            ps axww






                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Feb 23 at 15:12









                            glenn jackmanglenn jackman

                            16.3k32645




                            16.3k32645























                                0














                                ps checks whether its output goes to a terminal, and if so, queries the terminal's width. Then ps itself truncates each line according to that width. It's not the terminal chopping them, it doesn't even receive this data.






                                share|improve this answer




























                                  0














                                  ps checks whether its output goes to a terminal, and if so, queries the terminal's width. Then ps itself truncates each line according to that width. It's not the terminal chopping them, it doesn't even receive this data.






                                  share|improve this answer


























                                    0












                                    0








                                    0







                                    ps checks whether its output goes to a terminal, and if so, queries the terminal's width. Then ps itself truncates each line according to that width. It's not the terminal chopping them, it doesn't even receive this data.






                                    share|improve this answer













                                    ps checks whether its output goes to a terminal, and if so, queries the terminal's width. Then ps itself truncates each line according to that width. It's not the terminal chopping them, it doesn't even receive this data.







                                    share|improve this answer












                                    share|improve this answer



                                    share|improve this answer










                                    answered Feb 23 at 16:43









                                    egmontegmont

                                    1,5681814




                                    1,5681814






























                                        draft saved

                                        draft discarded




















































                                        Thanks for contributing an answer to Super User!


                                        • 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%2fsuperuser.com%2fquestions%2f1408774%2fforce-wrapping-the-long-output-lines-that-arent-so-in-terminal%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







                                        Popular posts from this blog

                                        How do I know what Microsoft account the skydrive app is syncing to?

                                        When does type information flow backwards in C++?

                                        Grease: Live!