Top-like command configurable from command line The 2019 Stack Overflow Developer Survey Results Are InUNIX-, BSD-, GNU-options in Linux's ps command. Where are they from?Queries about top commandTool for viewing top N items in streamThe shell command “top” shows which processes from the /proc directory?Top forest view with filter, can I include all children?How do I control the cycle length of “top” commandProgrammatically get CPUs 'detailed' usage, like top/htopTop command strange CPU% usageFilter top(1) display by COMMAND=abc OR COMMAND=xyzExclude chrome/firefox from top command outputhtop / top with specifying process name filter on the command line - at program startup?

How can I add encounters in the Lost Mine of Phandelver campaign without giving PCs too much XP?

How to obtain a position of last non-zero element

If I score a critical hit on an 18 or higher, what are my chances of getting a critical hit if I roll 3d20?

Does HR tell a hiring manager about salary negotiations?

APIPA and LAN Broadcast Domain

Are spiders unable to hurt humans, especially very small spiders?

Mathematics of imaging the black hole

If my opponent casts Ultimate Price on my Phantasmal Bear, can I save it by casting Snap or Curfew?

Is it a good practice to use a static variable in a Test Class and use that in the actual class instead of Test.isRunningTest()?

Can you cast a spell on someone in the Ethereal Plane, if you are on the Material Plane and have the True Seeing spell active?

Did any laptop computers have a built-in 5 1/4 inch floppy drive?

Kerning for subscripts of sigma?

Loose spokes after only a few rides

Why can't devices on different VLANs, but on the same subnet, communicate?

Geography at the pixel level

Can an undergraduate be advised by a professor who is very far away?

Old scifi movie from the 50s or 60s with men in solid red uniforms who interrogate a spy from the past

How do PCB vias affect signal quality?

Star Trek - X-shaped Item on Regula/Orbital Office Starbases

Deal with toxic manager when you can't quit

How to support a colleague who finds meetings extremely tiring?

Dropping list elements from nested list after evaluation

Why doesn't shell automatically fix "useless use of cat"?

How come people say “Would of”?



Top-like command configurable from command line



The 2019 Stack Overflow Developer Survey Results Are InUNIX-, BSD-, GNU-options in Linux's ps command. Where are they from?Queries about top commandTool for viewing top N items in streamThe shell command “top” shows which processes from the /proc directory?Top forest view with filter, can I include all children?How do I control the cycle length of “top” commandProgrammatically get CPUs 'detailed' usage, like top/htopTop command strange CPU% usageFilter top(1) display by COMMAND=abc OR COMMAND=xyzExclude chrome/firefox from top command outputhtop / top with specifying process name filter on the command line - at program startup?



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















For Ubuntu Bionic, is there a tool that will, like top, show various data on processes and refresh automatically, but can be configured from the command line to specify what data (columns) to show?










share|improve this question









New contributor




Yuri Geinish is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • @msp9011 like, only show the COMMAND column, which should be specified on the command line.

    – Yuri Geinish
    Apr 8 at 11:41

















1















For Ubuntu Bionic, is there a tool that will, like top, show various data on processes and refresh automatically, but can be configured from the command line to specify what data (columns) to show?










share|improve this question









New contributor




Yuri Geinish is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • @msp9011 like, only show the COMMAND column, which should be specified on the command line.

    – Yuri Geinish
    Apr 8 at 11:41













1












1








1








For Ubuntu Bionic, is there a tool that will, like top, show various data on processes and refresh automatically, but can be configured from the command line to specify what data (columns) to show?










share|improve this question









New contributor




Yuri Geinish is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












For Ubuntu Bionic, is there a tool that will, like top, show various data on processes and refresh automatically, but can be configured from the command line to specify what data (columns) to show?







ubuntu top






share|improve this question









New contributor




Yuri Geinish is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Yuri Geinish is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited Apr 8 at 11:25









Kusalananda

141k17263439




141k17263439






New contributor




Yuri Geinish is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked Apr 8 at 10:26









Yuri GeinishYuri Geinish

111




111




New contributor




Yuri Geinish is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Yuri Geinish is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Yuri Geinish is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • @msp9011 like, only show the COMMAND column, which should be specified on the command line.

    – Yuri Geinish
    Apr 8 at 11:41

















  • @msp9011 like, only show the COMMAND column, which should be specified on the command line.

    – Yuri Geinish
    Apr 8 at 11:41
















@msp9011 like, only show the COMMAND column, which should be specified on the command line.

– Yuri Geinish
Apr 8 at 11:41





@msp9011 like, only show the COMMAND column, which should be specified on the command line.

– Yuri Geinish
Apr 8 at 11:41










2 Answers
2






active

oldest

votes


















1














procps top, the one found on Ubuntu is probably the most configurable of top implementations.



To change the list of fields, press f and you can add remove fields, change their orders, etc.



There is a lot more you can change there, including colour, layout, including multi-pane views, the header at the top...



You can save those configuration by pressing W.



That will go to ~/.toprc (or ~/.config/procps/toprc in newer versions).



You can save them as a different profile by calling top with a different name. For instance, if you make a mytop symlink to the top executable, and invoke it, or run top as (exec -a mytop top), then W will save the configuration to ~/.mytoprc instead, so you can define a variety of differently flavoured versions of top that way.






share|improve this answer
































    -1














    It's a dilemma, isn't it?




    • top has automatic refresh, but no way to specify the columns to display.


    • ps and its ilk can be told what columns to output, but do not continually update.

    I am part of the way towards addressing this for myself.



    I already have a tool that can take the data of a table input over a pipe, and display it full screen on a terminal in a scrollable columnar format. It is the console-flat-table-viewer command from the nosh toolset. Feed it at intervals on its standard input a succession of tables, delimited by the relevant file separator character, and it will provide a continually updated display.



    Note that this is not like watch. watch takes any old input. console-flat-table-viewer expects its input to be a table, in one of the several well-known flat file encodings that one find on Unices and Linux operating systems, and its user interface presents it as a table, aligned into rows and columns and with headings and a cursor.



    The other part of the mechanism is a tool that emits the process table in such a flat file form in the first place, repeatedly at intervals, interspersing its output with a file separator. We almost, but do not quite, have this.



    One can feed it the output of the top command in its "batch" mode:


    while top -b all | sed -e '1,8s/^/#/' -e $'1i\n\f'
    do
    sleep 1
    done |
    console-flat-table-viewer --header-count 1


    The sed turns into comments the part of the top output that is not actually the process table, which would otherwise confuse the table layout, and adds in the file separator. In the table encoding that matches what top outputs, what the console-flat-table-viewer manual calls the space format, the file separator is the ␌ character, which has to be escaped for sed to not strip it. (ASCII has a real ␜ character, which console-flat-table-viewer understands for ascii tables. This is not the encoding that top outputs, though.)



    I add the ␌ character with sed to reduce display flicker, so that console-flat-table-viewer does not receive it until immediately before the rest of the table data. An alternative, which flickers slightly more because there is an interval between the ␌ and the table data during which console-flat-table-viewer displays a blank table, is to simply invoke printf first.



    Similarly, the commands that generate the output go in the condition of the while loop, so that the broken pipe when I quit console-flat-table-viewer causes the loop to gracefully terminate.



    But this does not provide control over columns.



    One can alternatively feed it the output of the FreeBSD procstat command:


    while printf 'f' ; procstat -a
    do
    sleep 1
    done |
    console-flat-table-viewer --header-count 1


    This has a limited degree of control over columns with its various options, but not fine grained control. It is also somewhat problematic because several of its options cause it to break the tabular format by emitting unescaped whitespace in the middle of fields.



    One could use the BSD ps command:


    while ps -a -x -o "pid,ppid,user,logname,time,state,wchan,start,comm" | sed -e $'1i\n\f'
    do
    sleep 1
    done |
    console-flat-table-viewer --header-count 1


    The GNU-licensed ps command on Ubuntu Linux has a different command-line syntax, which is several questions and answers in its own right, but one could employ it likewise.



    Whilst this does have fine-grained control over the columns, it again does not properly escape whitespace within fields.



    The BSDs have had a way of dealing with this since 4.4BSD in the 1990s. It is the vis() encoding system, which various BSD flat tables (such as /etc/fstab) already employ. console-flat-table-viewer already knows how to decode it, too. It would be very welcome for ps or procstat, preferably both, to be able to vis-encode their outputs.



    The obvious next step for GUI users is to have a (currently hypothetical) utility that substitutes for console-flat-table-viewer, taking the same input and leaving the input side of the pipeline the same, and displays continually updated tables with a GUI instead of a TUI.



    Then we could have a flexible mechanism made of composable tools joined together with pipes. ☺



    Further reading



    • Jonathan de Boyne Pollard (2019). console-flat-table-viewer. nosh Guide. Softwares.

    • "Roadmap". The nosh project. FreeBSD Quarterly Status Update 2018Q4.

    • Robert N M Watson (2017-01-14). procstat. FreeBSD General Commands Manual.


    • ps. FreeBSD General Commands Manual. 2018-03-13.


    • vis. FreeBSD General Commands Manual. 2013-02-19.

    • https://unix.stackexchange.com/a/511530/5132





    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',
      autoActivateHeartbeat: false,
      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
      );



      );






      Yuri Geinish is a new contributor. Be nice, and check out our Code of Conduct.









      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f511202%2ftop-like-command-configurable-from-command-line%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









      1














      procps top, the one found on Ubuntu is probably the most configurable of top implementations.



      To change the list of fields, press f and you can add remove fields, change their orders, etc.



      There is a lot more you can change there, including colour, layout, including multi-pane views, the header at the top...



      You can save those configuration by pressing W.



      That will go to ~/.toprc (or ~/.config/procps/toprc in newer versions).



      You can save them as a different profile by calling top with a different name. For instance, if you make a mytop symlink to the top executable, and invoke it, or run top as (exec -a mytop top), then W will save the configuration to ~/.mytoprc instead, so you can define a variety of differently flavoured versions of top that way.






      share|improve this answer





























        1














        procps top, the one found on Ubuntu is probably the most configurable of top implementations.



        To change the list of fields, press f and you can add remove fields, change their orders, etc.



        There is a lot more you can change there, including colour, layout, including multi-pane views, the header at the top...



        You can save those configuration by pressing W.



        That will go to ~/.toprc (or ~/.config/procps/toprc in newer versions).



        You can save them as a different profile by calling top with a different name. For instance, if you make a mytop symlink to the top executable, and invoke it, or run top as (exec -a mytop top), then W will save the configuration to ~/.mytoprc instead, so you can define a variety of differently flavoured versions of top that way.






        share|improve this answer



























          1












          1








          1







          procps top, the one found on Ubuntu is probably the most configurable of top implementations.



          To change the list of fields, press f and you can add remove fields, change their orders, etc.



          There is a lot more you can change there, including colour, layout, including multi-pane views, the header at the top...



          You can save those configuration by pressing W.



          That will go to ~/.toprc (or ~/.config/procps/toprc in newer versions).



          You can save them as a different profile by calling top with a different name. For instance, if you make a mytop symlink to the top executable, and invoke it, or run top as (exec -a mytop top), then W will save the configuration to ~/.mytoprc instead, so you can define a variety of differently flavoured versions of top that way.






          share|improve this answer















          procps top, the one found on Ubuntu is probably the most configurable of top implementations.



          To change the list of fields, press f and you can add remove fields, change their orders, etc.



          There is a lot more you can change there, including colour, layout, including multi-pane views, the header at the top...



          You can save those configuration by pressing W.



          That will go to ~/.toprc (or ~/.config/procps/toprc in newer versions).



          You can save them as a different profile by calling top with a different name. For instance, if you make a mytop symlink to the top executable, and invoke it, or run top as (exec -a mytop top), then W will save the configuration to ~/.mytoprc instead, so you can define a variety of differently flavoured versions of top that way.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 2 days ago

























          answered 2 days ago









          Stéphane ChazelasStéphane Chazelas

          314k57594952




          314k57594952























              -1














              It's a dilemma, isn't it?




              • top has automatic refresh, but no way to specify the columns to display.


              • ps and its ilk can be told what columns to output, but do not continually update.

              I am part of the way towards addressing this for myself.



              I already have a tool that can take the data of a table input over a pipe, and display it full screen on a terminal in a scrollable columnar format. It is the console-flat-table-viewer command from the nosh toolset. Feed it at intervals on its standard input a succession of tables, delimited by the relevant file separator character, and it will provide a continually updated display.



              Note that this is not like watch. watch takes any old input. console-flat-table-viewer expects its input to be a table, in one of the several well-known flat file encodings that one find on Unices and Linux operating systems, and its user interface presents it as a table, aligned into rows and columns and with headings and a cursor.



              The other part of the mechanism is a tool that emits the process table in such a flat file form in the first place, repeatedly at intervals, interspersing its output with a file separator. We almost, but do not quite, have this.



              One can feed it the output of the top command in its "batch" mode:


              while top -b all | sed -e '1,8s/^/#/' -e $'1i\n\f'
              do
              sleep 1
              done |
              console-flat-table-viewer --header-count 1


              The sed turns into comments the part of the top output that is not actually the process table, which would otherwise confuse the table layout, and adds in the file separator. In the table encoding that matches what top outputs, what the console-flat-table-viewer manual calls the space format, the file separator is the ␌ character, which has to be escaped for sed to not strip it. (ASCII has a real ␜ character, which console-flat-table-viewer understands for ascii tables. This is not the encoding that top outputs, though.)



              I add the ␌ character with sed to reduce display flicker, so that console-flat-table-viewer does not receive it until immediately before the rest of the table data. An alternative, which flickers slightly more because there is an interval between the ␌ and the table data during which console-flat-table-viewer displays a blank table, is to simply invoke printf first.



              Similarly, the commands that generate the output go in the condition of the while loop, so that the broken pipe when I quit console-flat-table-viewer causes the loop to gracefully terminate.



              But this does not provide control over columns.



              One can alternatively feed it the output of the FreeBSD procstat command:


              while printf 'f' ; procstat -a
              do
              sleep 1
              done |
              console-flat-table-viewer --header-count 1


              This has a limited degree of control over columns with its various options, but not fine grained control. It is also somewhat problematic because several of its options cause it to break the tabular format by emitting unescaped whitespace in the middle of fields.



              One could use the BSD ps command:


              while ps -a -x -o "pid,ppid,user,logname,time,state,wchan,start,comm" | sed -e $'1i\n\f'
              do
              sleep 1
              done |
              console-flat-table-viewer --header-count 1


              The GNU-licensed ps command on Ubuntu Linux has a different command-line syntax, which is several questions and answers in its own right, but one could employ it likewise.



              Whilst this does have fine-grained control over the columns, it again does not properly escape whitespace within fields.



              The BSDs have had a way of dealing with this since 4.4BSD in the 1990s. It is the vis() encoding system, which various BSD flat tables (such as /etc/fstab) already employ. console-flat-table-viewer already knows how to decode it, too. It would be very welcome for ps or procstat, preferably both, to be able to vis-encode their outputs.



              The obvious next step for GUI users is to have a (currently hypothetical) utility that substitutes for console-flat-table-viewer, taking the same input and leaving the input side of the pipeline the same, and displays continually updated tables with a GUI instead of a TUI.



              Then we could have a flexible mechanism made of composable tools joined together with pipes. ☺



              Further reading



              • Jonathan de Boyne Pollard (2019). console-flat-table-viewer. nosh Guide. Softwares.

              • "Roadmap". The nosh project. FreeBSD Quarterly Status Update 2018Q4.

              • Robert N M Watson (2017-01-14). procstat. FreeBSD General Commands Manual.


              • ps. FreeBSD General Commands Manual. 2018-03-13.


              • vis. FreeBSD General Commands Manual. 2013-02-19.

              • https://unix.stackexchange.com/a/511530/5132





              share|improve this answer





























                -1














                It's a dilemma, isn't it?




                • top has automatic refresh, but no way to specify the columns to display.


                • ps and its ilk can be told what columns to output, but do not continually update.

                I am part of the way towards addressing this for myself.



                I already have a tool that can take the data of a table input over a pipe, and display it full screen on a terminal in a scrollable columnar format. It is the console-flat-table-viewer command from the nosh toolset. Feed it at intervals on its standard input a succession of tables, delimited by the relevant file separator character, and it will provide a continually updated display.



                Note that this is not like watch. watch takes any old input. console-flat-table-viewer expects its input to be a table, in one of the several well-known flat file encodings that one find on Unices and Linux operating systems, and its user interface presents it as a table, aligned into rows and columns and with headings and a cursor.



                The other part of the mechanism is a tool that emits the process table in such a flat file form in the first place, repeatedly at intervals, interspersing its output with a file separator. We almost, but do not quite, have this.



                One can feed it the output of the top command in its "batch" mode:


                while top -b all | sed -e '1,8s/^/#/' -e $'1i\n\f'
                do
                sleep 1
                done |
                console-flat-table-viewer --header-count 1


                The sed turns into comments the part of the top output that is not actually the process table, which would otherwise confuse the table layout, and adds in the file separator. In the table encoding that matches what top outputs, what the console-flat-table-viewer manual calls the space format, the file separator is the ␌ character, which has to be escaped for sed to not strip it. (ASCII has a real ␜ character, which console-flat-table-viewer understands for ascii tables. This is not the encoding that top outputs, though.)



                I add the ␌ character with sed to reduce display flicker, so that console-flat-table-viewer does not receive it until immediately before the rest of the table data. An alternative, which flickers slightly more because there is an interval between the ␌ and the table data during which console-flat-table-viewer displays a blank table, is to simply invoke printf first.



                Similarly, the commands that generate the output go in the condition of the while loop, so that the broken pipe when I quit console-flat-table-viewer causes the loop to gracefully terminate.



                But this does not provide control over columns.



                One can alternatively feed it the output of the FreeBSD procstat command:


                while printf 'f' ; procstat -a
                do
                sleep 1
                done |
                console-flat-table-viewer --header-count 1


                This has a limited degree of control over columns with its various options, but not fine grained control. It is also somewhat problematic because several of its options cause it to break the tabular format by emitting unescaped whitespace in the middle of fields.



                One could use the BSD ps command:


                while ps -a -x -o "pid,ppid,user,logname,time,state,wchan,start,comm" | sed -e $'1i\n\f'
                do
                sleep 1
                done |
                console-flat-table-viewer --header-count 1


                The GNU-licensed ps command on Ubuntu Linux has a different command-line syntax, which is several questions and answers in its own right, but one could employ it likewise.



                Whilst this does have fine-grained control over the columns, it again does not properly escape whitespace within fields.



                The BSDs have had a way of dealing with this since 4.4BSD in the 1990s. It is the vis() encoding system, which various BSD flat tables (such as /etc/fstab) already employ. console-flat-table-viewer already knows how to decode it, too. It would be very welcome for ps or procstat, preferably both, to be able to vis-encode their outputs.



                The obvious next step for GUI users is to have a (currently hypothetical) utility that substitutes for console-flat-table-viewer, taking the same input and leaving the input side of the pipeline the same, and displays continually updated tables with a GUI instead of a TUI.



                Then we could have a flexible mechanism made of composable tools joined together with pipes. ☺



                Further reading



                • Jonathan de Boyne Pollard (2019). console-flat-table-viewer. nosh Guide. Softwares.

                • "Roadmap". The nosh project. FreeBSD Quarterly Status Update 2018Q4.

                • Robert N M Watson (2017-01-14). procstat. FreeBSD General Commands Manual.


                • ps. FreeBSD General Commands Manual. 2018-03-13.


                • vis. FreeBSD General Commands Manual. 2013-02-19.

                • https://unix.stackexchange.com/a/511530/5132





                share|improve this answer



























                  -1












                  -1








                  -1







                  It's a dilemma, isn't it?




                  • top has automatic refresh, but no way to specify the columns to display.


                  • ps and its ilk can be told what columns to output, but do not continually update.

                  I am part of the way towards addressing this for myself.



                  I already have a tool that can take the data of a table input over a pipe, and display it full screen on a terminal in a scrollable columnar format. It is the console-flat-table-viewer command from the nosh toolset. Feed it at intervals on its standard input a succession of tables, delimited by the relevant file separator character, and it will provide a continually updated display.



                  Note that this is not like watch. watch takes any old input. console-flat-table-viewer expects its input to be a table, in one of the several well-known flat file encodings that one find on Unices and Linux operating systems, and its user interface presents it as a table, aligned into rows and columns and with headings and a cursor.



                  The other part of the mechanism is a tool that emits the process table in such a flat file form in the first place, repeatedly at intervals, interspersing its output with a file separator. We almost, but do not quite, have this.



                  One can feed it the output of the top command in its "batch" mode:


                  while top -b all | sed -e '1,8s/^/#/' -e $'1i\n\f'
                  do
                  sleep 1
                  done |
                  console-flat-table-viewer --header-count 1


                  The sed turns into comments the part of the top output that is not actually the process table, which would otherwise confuse the table layout, and adds in the file separator. In the table encoding that matches what top outputs, what the console-flat-table-viewer manual calls the space format, the file separator is the ␌ character, which has to be escaped for sed to not strip it. (ASCII has a real ␜ character, which console-flat-table-viewer understands for ascii tables. This is not the encoding that top outputs, though.)



                  I add the ␌ character with sed to reduce display flicker, so that console-flat-table-viewer does not receive it until immediately before the rest of the table data. An alternative, which flickers slightly more because there is an interval between the ␌ and the table data during which console-flat-table-viewer displays a blank table, is to simply invoke printf first.



                  Similarly, the commands that generate the output go in the condition of the while loop, so that the broken pipe when I quit console-flat-table-viewer causes the loop to gracefully terminate.



                  But this does not provide control over columns.



                  One can alternatively feed it the output of the FreeBSD procstat command:


                  while printf 'f' ; procstat -a
                  do
                  sleep 1
                  done |
                  console-flat-table-viewer --header-count 1


                  This has a limited degree of control over columns with its various options, but not fine grained control. It is also somewhat problematic because several of its options cause it to break the tabular format by emitting unescaped whitespace in the middle of fields.



                  One could use the BSD ps command:


                  while ps -a -x -o "pid,ppid,user,logname,time,state,wchan,start,comm" | sed -e $'1i\n\f'
                  do
                  sleep 1
                  done |
                  console-flat-table-viewer --header-count 1


                  The GNU-licensed ps command on Ubuntu Linux has a different command-line syntax, which is several questions and answers in its own right, but one could employ it likewise.



                  Whilst this does have fine-grained control over the columns, it again does not properly escape whitespace within fields.



                  The BSDs have had a way of dealing with this since 4.4BSD in the 1990s. It is the vis() encoding system, which various BSD flat tables (such as /etc/fstab) already employ. console-flat-table-viewer already knows how to decode it, too. It would be very welcome for ps or procstat, preferably both, to be able to vis-encode their outputs.



                  The obvious next step for GUI users is to have a (currently hypothetical) utility that substitutes for console-flat-table-viewer, taking the same input and leaving the input side of the pipeline the same, and displays continually updated tables with a GUI instead of a TUI.



                  Then we could have a flexible mechanism made of composable tools joined together with pipes. ☺



                  Further reading



                  • Jonathan de Boyne Pollard (2019). console-flat-table-viewer. nosh Guide. Softwares.

                  • "Roadmap". The nosh project. FreeBSD Quarterly Status Update 2018Q4.

                  • Robert N M Watson (2017-01-14). procstat. FreeBSD General Commands Manual.


                  • ps. FreeBSD General Commands Manual. 2018-03-13.


                  • vis. FreeBSD General Commands Manual. 2013-02-19.

                  • https://unix.stackexchange.com/a/511530/5132





                  share|improve this answer















                  It's a dilemma, isn't it?




                  • top has automatic refresh, but no way to specify the columns to display.


                  • ps and its ilk can be told what columns to output, but do not continually update.

                  I am part of the way towards addressing this for myself.



                  I already have a tool that can take the data of a table input over a pipe, and display it full screen on a terminal in a scrollable columnar format. It is the console-flat-table-viewer command from the nosh toolset. Feed it at intervals on its standard input a succession of tables, delimited by the relevant file separator character, and it will provide a continually updated display.



                  Note that this is not like watch. watch takes any old input. console-flat-table-viewer expects its input to be a table, in one of the several well-known flat file encodings that one find on Unices and Linux operating systems, and its user interface presents it as a table, aligned into rows and columns and with headings and a cursor.



                  The other part of the mechanism is a tool that emits the process table in such a flat file form in the first place, repeatedly at intervals, interspersing its output with a file separator. We almost, but do not quite, have this.



                  One can feed it the output of the top command in its "batch" mode:


                  while top -b all | sed -e '1,8s/^/#/' -e $'1i\n\f'
                  do
                  sleep 1
                  done |
                  console-flat-table-viewer --header-count 1


                  The sed turns into comments the part of the top output that is not actually the process table, which would otherwise confuse the table layout, and adds in the file separator. In the table encoding that matches what top outputs, what the console-flat-table-viewer manual calls the space format, the file separator is the ␌ character, which has to be escaped for sed to not strip it. (ASCII has a real ␜ character, which console-flat-table-viewer understands for ascii tables. This is not the encoding that top outputs, though.)



                  I add the ␌ character with sed to reduce display flicker, so that console-flat-table-viewer does not receive it until immediately before the rest of the table data. An alternative, which flickers slightly more because there is an interval between the ␌ and the table data during which console-flat-table-viewer displays a blank table, is to simply invoke printf first.



                  Similarly, the commands that generate the output go in the condition of the while loop, so that the broken pipe when I quit console-flat-table-viewer causes the loop to gracefully terminate.



                  But this does not provide control over columns.



                  One can alternatively feed it the output of the FreeBSD procstat command:


                  while printf 'f' ; procstat -a
                  do
                  sleep 1
                  done |
                  console-flat-table-viewer --header-count 1


                  This has a limited degree of control over columns with its various options, but not fine grained control. It is also somewhat problematic because several of its options cause it to break the tabular format by emitting unescaped whitespace in the middle of fields.



                  One could use the BSD ps command:


                  while ps -a -x -o "pid,ppid,user,logname,time,state,wchan,start,comm" | sed -e $'1i\n\f'
                  do
                  sleep 1
                  done |
                  console-flat-table-viewer --header-count 1


                  The GNU-licensed ps command on Ubuntu Linux has a different command-line syntax, which is several questions and answers in its own right, but one could employ it likewise.



                  Whilst this does have fine-grained control over the columns, it again does not properly escape whitespace within fields.



                  The BSDs have had a way of dealing with this since 4.4BSD in the 1990s. It is the vis() encoding system, which various BSD flat tables (such as /etc/fstab) already employ. console-flat-table-viewer already knows how to decode it, too. It would be very welcome for ps or procstat, preferably both, to be able to vis-encode their outputs.



                  The obvious next step for GUI users is to have a (currently hypothetical) utility that substitutes for console-flat-table-viewer, taking the same input and leaving the input side of the pipeline the same, and displays continually updated tables with a GUI instead of a TUI.



                  Then we could have a flexible mechanism made of composable tools joined together with pipes. ☺



                  Further reading



                  • Jonathan de Boyne Pollard (2019). console-flat-table-viewer. nosh Guide. Softwares.

                  • "Roadmap". The nosh project. FreeBSD Quarterly Status Update 2018Q4.

                  • Robert N M Watson (2017-01-14). procstat. FreeBSD General Commands Manual.


                  • ps. FreeBSD General Commands Manual. 2018-03-13.


                  • vis. FreeBSD General Commands Manual. 2013-02-19.

                  • https://unix.stackexchange.com/a/511530/5132






                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited 2 days ago

























                  answered Apr 8 at 13:06









                  JdeBPJdeBP

                  38k478183




                  38k478183




















                      Yuri Geinish is a new contributor. Be nice, and check out our Code of Conduct.









                      draft saved

                      draft discarded


















                      Yuri Geinish is a new contributor. Be nice, and check out our Code of Conduct.












                      Yuri Geinish is a new contributor. Be nice, and check out our Code of Conduct.











                      Yuri Geinish is a new contributor. Be nice, and check out our Code of Conduct.














                      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.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f511202%2ftop-like-command-configurable-from-command-line%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

                      getting Checkpoint VPN SSL Network Extender working in the command lineHow to connect to CheckPoint VPN on Ubuntu 18.04LTS?Will the Linux ( red-hat ) Open VPNC Client connect to checkpoint or nortel VPN gateways?VPN client for linux machine + support checkpoint gatewayVPN SSL Network Extender in FirefoxLinux Checkpoint SNX tool configuration issuesCheck Point - Connect under Linux - snx + OTPSNX VPN Ububuntu 18.XXUsing Checkpoint VPN SSL Network Extender CLI with certificateVPN with network manager (nm-applet) is not workingWill the Linux ( red-hat ) Open VPNC Client connect to checkpoint or nortel VPN gateways?VPN client for linux machine + support checkpoint gatewayImport VPN config files to NetworkManager from command lineTrouble connecting to VPN using network-manager, while command line worksStart a VPN connection with PPTP protocol on command linestarting a docker service daemon breaks the vpn networkCan't connect to vpn with Network-managerVPN SSL Network Extender in FirefoxUsing Checkpoint VPN SSL Network Extender CLI with certificate

                      Cannot Extend partition with GParted The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) 2019 Community Moderator Election ResultsCan't increase partition size with GParted?GParted doesn't recognize the unallocated space after my current partitionWhat is the best way to add unallocated space located before to Ubuntu 12.04 partition with GParted live?I can't figure out how to extend my Arch home partition into free spaceGparted Linux Mint 18.1 issueTrying to extend but swap partition is showing as Unknown in Gparted, shows proper from fdiskRearrange partitions in gparted to extend a partitionUnable to extend partition even though unallocated space is next to it using GPartedAllocate free space to root partitiongparted: how to merge unallocated space with a partition

                      Marilyn Monroe Ny fiainany manokana | Jereo koa | Meny fitetezanafanitarana azy.