Next command output on the same line? Bash scriptSet bash script output to the line that called bash scriptprint the output of 2 commands in 1 file on the same lineBash: How do I make a command line call a script and pass two strings?How use an if statement to change the output messagereformatting command output within bash scriptBash print current line, line's output, and linebreak to filegrep script - output lines at the same time into echofind command not giving any outputvariable content is different than the output of the assigned commandHow to get du -ksh working without a carriage return in shell-scripting?

show stdout containing n with line breaks

Acceptable to cut steak before searing?

Why aren’t emergency services using callsigns?

Can a spacecraft use an accelerometer to determine its orientation?

Ordering a word list

If a Contingency spell has been cast on a creature, does the Simulacrum spell transfer the contingent spell to its duplicate?

Y2K... in 2019?

PHP santization of textarea input

Best gun to modify into a monsterhunter weapon?

Why are the inside diameters of some pipe larger than the stated size?

In a topological space if there exists a loop that cannot be contracted to a point does there exist a simple loop that cannot be contracted also?

Was the 2019 Lion King film made through motion capture?

How do I calculate the difference in lens reach between a superzoom compact and a DSLR zoom lens?

Is refreshing multiple times a test case for web applications?

What are good ways to improve as a writer other than writing courses?

Do other countries guarantee freedoms that the United States does not have?

Does this Foo machine halt?

First amendment and employment: Can an employer terminate you for speech?

As a 16 year old, how can I keep my money safe from my mother?

Does a code snippet compile? Or does it get compiled?

Does two puncture wounds mean venomous snake?

Dereferencing a pointer in a 'for' loop initializer creates a segmentation fault

Can I call myself an assistant professor without a PhD?

How can you evade tax by getting employment income just in equity, then using this equity as collateral to take out loan?



Next command output on the same line? Bash script


Set bash script output to the line that called bash scriptprint the output of 2 commands in 1 file on the same lineBash: How do I make a command line call a script and pass two strings?How use an if statement to change the output messagereformatting command output within bash scriptBash print current line, line's output, and linebreak to filegrep script - output lines at the same time into echofind command not giving any outputvariable content is different than the output of the assigned commandHow to get du -ksh working without a carriage return in shell-scripting?






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








2















I have the following simple script:



echo "-------------------------- SOA --------------------------------"
echo " "
echo -n " ---------> "; dig soa "$1" +short | awk 'print $3'


The output is something like this:



-------------------------- SOA --------------------------------

---------> 2019072905


Now my question is can I make an "echo" command after the dig and the output to be something like this:



-------------------------- SOA -----------------------------

---------> 2019072905 <-------------


I have tried to search for similar cases but was not able to find any related.



Would this be possible?



Thanks in advance.










share|improve this question






























    2















    I have the following simple script:



    echo "-------------------------- SOA --------------------------------"
    echo " "
    echo -n " ---------> "; dig soa "$1" +short | awk 'print $3'


    The output is something like this:



    -------------------------- SOA --------------------------------

    ---------> 2019072905


    Now my question is can I make an "echo" command after the dig and the output to be something like this:



    -------------------------- SOA -----------------------------

    ---------> 2019072905 <-------------


    I have tried to search for similar cases but was not able to find any related.



    Would this be possible?



    Thanks in advance.










    share|improve this question


























      2












      2








      2








      I have the following simple script:



      echo "-------------------------- SOA --------------------------------"
      echo " "
      echo -n " ---------> "; dig soa "$1" +short | awk 'print $3'


      The output is something like this:



      -------------------------- SOA --------------------------------

      ---------> 2019072905


      Now my question is can I make an "echo" command after the dig and the output to be something like this:



      -------------------------- SOA -----------------------------

      ---------> 2019072905 <-------------


      I have tried to search for similar cases but was not able to find any related.



      Would this be possible?



      Thanks in advance.










      share|improve this question














      I have the following simple script:



      echo "-------------------------- SOA --------------------------------"
      echo " "
      echo -n " ---------> "; dig soa "$1" +short | awk 'print $3'


      The output is something like this:



      -------------------------- SOA --------------------------------

      ---------> 2019072905


      Now my question is can I make an "echo" command after the dig and the output to be something like this:



      -------------------------- SOA -----------------------------

      ---------> 2019072905 <-------------


      I have tried to search for similar cases but was not able to find any related.



      Would this be possible?



      Thanks in advance.







      bash shell-script echo output






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jul 30 at 11:28









      MiroMiro

      273 bronze badges




      273 bronze badges























          4 Answers
          4






          active

          oldest

          votes


















          2














          I would do the whole thing in printf instead:





          #!/bin/sh

          header='-------------------------- SOA --------------------------'

          headerLength=$(awk 'print length()' <<<"$header")

          value=$(dig soa "$1" +short | awk 'print $3')

          valueString="-----------> $value <-------------"

          valueLength=$(awk 'print length()' <<<"$valueString")

          offset=$(((headerLength + valueLength)/2+1))

          printf "%snn%$offsetsn" "$header" "$valueString"


          This has the advantage of always appearing centered no matter what the length of your value is (using a slightly modified version that just sets value=$1 to illustrate):



          $ foo.sh 2019072905
          -------------------------- SOA --------------------------------

          -----------> 2019072905 <-------------
          $ foo.sh "some random long string"
          -------------------------- SOA --------------------------------

          -----------> some random long string <-------------
          $ foo.sh "foo"
          -------------------------- SOA --------------------------

          -----------> foo <-------------





          share|improve this answer

























          • Thanks for your advice. Will check this out with 'printf' also.

            – Miro
            Jul 30 at 12:20


















          2














          #!/bin/sh

          soa=$(dig soa "$1" +short | awk 'print $3')

          cat <<__EOF__
          -------------------------- SOA -----------------------------

          ---------> $soa <-------------
          __EOF__



          BTW, I think the question is wrong-headed because printing all that header garbage around the SOA just makes it pointlessly harder to use the output of this script as input to another script...and even when you don't currently think you'll ever need to do that, in future you might. Verbosity in output is a "sin" in unix :) - when writing a script, you should always be thinking that your output could end up being someone else's (including yourself) input.



          I would have ignored the question, but I disliked the other answer even more. If you're going to do something wrong, you may as well do it properly.






          share|improve this answer



























          • Thank you for your advice. Will have this in mind. Atm, this is only for personal use combining several commands in a small script.

            – Miro
            Jul 30 at 12:10











          • that's cool. i have no objection to you doing whatever you want for your own needs or education....but that answer combining the output of dig ... |awk ... with the echo statement just irked me. it's bad coding style and it's teaching bad habits.

            – cas
            Jul 30 at 12:27



















          1














          cmd=$(dig soa "$1" +short | awk 'print $3'; echo -n <----------;)

          echo "-------------------------- SOA --------------------------------"
          echo " "
          echo -n " ---------> ";echo $cmd





          share|improve this answer

























          • Thanks. This is indeed something that I was looking for.

            – Miro
            Jul 30 at 12:11


















          -1














          I don't have dig so used echo in it's place for this example:



          $ echo '2019072905' | awk '
          BEGIN d=sprintf("%15s",""); gsub(/ /,"-",d); print d d, "SOA", d d ORS
          printf "%*s> %s <%sn", 2*length(d)-length($0)/2+1, d, $0, d
          '
          ------------------------------ SOA ------------------------------

          ---------------> 2019072905 <---------------

          $ echo '201' | awk '
          BEGIN d=sprintf("%15s",""); gsub(/ /,"-",d); print d d, "SOA", d d ORS
          printf "%*s> %s <%sn", 2*length(d)-length($0)/2+1, d, $0, d
          '
          ------------------------------ SOA ------------------------------

          ---------------> 201 <---------------

          $ echo '12345672019072905' | awk '
          BEGIN d=sprintf("%15s",""); gsub(/ /,"-",d); print d d, "SOA", d d ORS
          printf "%*s> %s <%sn", 2*length(d)-length($0)/2+1, d, $0, d
          '
          ------------------------------ SOA ------------------------------

          ---------------> 12345672019072905 <---------------





          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
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f532938%2fnext-command-output-on-the-same-line-bash-script%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            4 Answers
            4






            active

            oldest

            votes








            4 Answers
            4






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            2














            I would do the whole thing in printf instead:





            #!/bin/sh

            header='-------------------------- SOA --------------------------'

            headerLength=$(awk 'print length()' <<<"$header")

            value=$(dig soa "$1" +short | awk 'print $3')

            valueString="-----------> $value <-------------"

            valueLength=$(awk 'print length()' <<<"$valueString")

            offset=$(((headerLength + valueLength)/2+1))

            printf "%snn%$offsetsn" "$header" "$valueString"


            This has the advantage of always appearing centered no matter what the length of your value is (using a slightly modified version that just sets value=$1 to illustrate):



            $ foo.sh 2019072905
            -------------------------- SOA --------------------------------

            -----------> 2019072905 <-------------
            $ foo.sh "some random long string"
            -------------------------- SOA --------------------------------

            -----------> some random long string <-------------
            $ foo.sh "foo"
            -------------------------- SOA --------------------------

            -----------> foo <-------------





            share|improve this answer

























            • Thanks for your advice. Will check this out with 'printf' also.

              – Miro
              Jul 30 at 12:20















            2














            I would do the whole thing in printf instead:





            #!/bin/sh

            header='-------------------------- SOA --------------------------'

            headerLength=$(awk 'print length()' <<<"$header")

            value=$(dig soa "$1" +short | awk 'print $3')

            valueString="-----------> $value <-------------"

            valueLength=$(awk 'print length()' <<<"$valueString")

            offset=$(((headerLength + valueLength)/2+1))

            printf "%snn%$offsetsn" "$header" "$valueString"


            This has the advantage of always appearing centered no matter what the length of your value is (using a slightly modified version that just sets value=$1 to illustrate):



            $ foo.sh 2019072905
            -------------------------- SOA --------------------------------

            -----------> 2019072905 <-------------
            $ foo.sh "some random long string"
            -------------------------- SOA --------------------------------

            -----------> some random long string <-------------
            $ foo.sh "foo"
            -------------------------- SOA --------------------------

            -----------> foo <-------------





            share|improve this answer

























            • Thanks for your advice. Will check this out with 'printf' also.

              – Miro
              Jul 30 at 12:20













            2












            2








            2







            I would do the whole thing in printf instead:





            #!/bin/sh

            header='-------------------------- SOA --------------------------'

            headerLength=$(awk 'print length()' <<<"$header")

            value=$(dig soa "$1" +short | awk 'print $3')

            valueString="-----------> $value <-------------"

            valueLength=$(awk 'print length()' <<<"$valueString")

            offset=$(((headerLength + valueLength)/2+1))

            printf "%snn%$offsetsn" "$header" "$valueString"


            This has the advantage of always appearing centered no matter what the length of your value is (using a slightly modified version that just sets value=$1 to illustrate):



            $ foo.sh 2019072905
            -------------------------- SOA --------------------------------

            -----------> 2019072905 <-------------
            $ foo.sh "some random long string"
            -------------------------- SOA --------------------------------

            -----------> some random long string <-------------
            $ foo.sh "foo"
            -------------------------- SOA --------------------------

            -----------> foo <-------------





            share|improve this answer













            I would do the whole thing in printf instead:





            #!/bin/sh

            header='-------------------------- SOA --------------------------'

            headerLength=$(awk 'print length()' <<<"$header")

            value=$(dig soa "$1" +short | awk 'print $3')

            valueString="-----------> $value <-------------"

            valueLength=$(awk 'print length()' <<<"$valueString")

            offset=$(((headerLength + valueLength)/2+1))

            printf "%snn%$offsetsn" "$header" "$valueString"


            This has the advantage of always appearing centered no matter what the length of your value is (using a slightly modified version that just sets value=$1 to illustrate):



            $ foo.sh 2019072905
            -------------------------- SOA --------------------------------

            -----------> 2019072905 <-------------
            $ foo.sh "some random long string"
            -------------------------- SOA --------------------------------

            -----------> some random long string <-------------
            $ foo.sh "foo"
            -------------------------- SOA --------------------------

            -----------> foo <-------------






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Jul 30 at 12:06









            terdonterdon

            140k34 gold badges287 silver badges466 bronze badges




            140k34 gold badges287 silver badges466 bronze badges















            • Thanks for your advice. Will check this out with 'printf' also.

              – Miro
              Jul 30 at 12:20

















            • Thanks for your advice. Will check this out with 'printf' also.

              – Miro
              Jul 30 at 12:20
















            Thanks for your advice. Will check this out with 'printf' also.

            – Miro
            Jul 30 at 12:20





            Thanks for your advice. Will check this out with 'printf' also.

            – Miro
            Jul 30 at 12:20













            2














            #!/bin/sh

            soa=$(dig soa "$1" +short | awk 'print $3')

            cat <<__EOF__
            -------------------------- SOA -----------------------------

            ---------> $soa <-------------
            __EOF__



            BTW, I think the question is wrong-headed because printing all that header garbage around the SOA just makes it pointlessly harder to use the output of this script as input to another script...and even when you don't currently think you'll ever need to do that, in future you might. Verbosity in output is a "sin" in unix :) - when writing a script, you should always be thinking that your output could end up being someone else's (including yourself) input.



            I would have ignored the question, but I disliked the other answer even more. If you're going to do something wrong, you may as well do it properly.






            share|improve this answer



























            • Thank you for your advice. Will have this in mind. Atm, this is only for personal use combining several commands in a small script.

              – Miro
              Jul 30 at 12:10











            • that's cool. i have no objection to you doing whatever you want for your own needs or education....but that answer combining the output of dig ... |awk ... with the echo statement just irked me. it's bad coding style and it's teaching bad habits.

              – cas
              Jul 30 at 12:27
















            2














            #!/bin/sh

            soa=$(dig soa "$1" +short | awk 'print $3')

            cat <<__EOF__
            -------------------------- SOA -----------------------------

            ---------> $soa <-------------
            __EOF__



            BTW, I think the question is wrong-headed because printing all that header garbage around the SOA just makes it pointlessly harder to use the output of this script as input to another script...and even when you don't currently think you'll ever need to do that, in future you might. Verbosity in output is a "sin" in unix :) - when writing a script, you should always be thinking that your output could end up being someone else's (including yourself) input.



            I would have ignored the question, but I disliked the other answer even more. If you're going to do something wrong, you may as well do it properly.






            share|improve this answer



























            • Thank you for your advice. Will have this in mind. Atm, this is only for personal use combining several commands in a small script.

              – Miro
              Jul 30 at 12:10











            • that's cool. i have no objection to you doing whatever you want for your own needs or education....but that answer combining the output of dig ... |awk ... with the echo statement just irked me. it's bad coding style and it's teaching bad habits.

              – cas
              Jul 30 at 12:27














            2












            2








            2







            #!/bin/sh

            soa=$(dig soa "$1" +short | awk 'print $3')

            cat <<__EOF__
            -------------------------- SOA -----------------------------

            ---------> $soa <-------------
            __EOF__



            BTW, I think the question is wrong-headed because printing all that header garbage around the SOA just makes it pointlessly harder to use the output of this script as input to another script...and even when you don't currently think you'll ever need to do that, in future you might. Verbosity in output is a "sin" in unix :) - when writing a script, you should always be thinking that your output could end up being someone else's (including yourself) input.



            I would have ignored the question, but I disliked the other answer even more. If you're going to do something wrong, you may as well do it properly.






            share|improve this answer















            #!/bin/sh

            soa=$(dig soa "$1" +short | awk 'print $3')

            cat <<__EOF__
            -------------------------- SOA -----------------------------

            ---------> $soa <-------------
            __EOF__



            BTW, I think the question is wrong-headed because printing all that header garbage around the SOA just makes it pointlessly harder to use the output of this script as input to another script...and even when you don't currently think you'll ever need to do that, in future you might. Verbosity in output is a "sin" in unix :) - when writing a script, you should always be thinking that your output could end up being someone else's (including yourself) input.



            I would have ignored the question, but I disliked the other answer even more. If you're going to do something wrong, you may as well do it properly.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Jul 30 at 11:59

























            answered Jul 30 at 11:50









            cascas

            41.1k4 gold badges59 silver badges110 bronze badges




            41.1k4 gold badges59 silver badges110 bronze badges















            • Thank you for your advice. Will have this in mind. Atm, this is only for personal use combining several commands in a small script.

              – Miro
              Jul 30 at 12:10











            • that's cool. i have no objection to you doing whatever you want for your own needs or education....but that answer combining the output of dig ... |awk ... with the echo statement just irked me. it's bad coding style and it's teaching bad habits.

              – cas
              Jul 30 at 12:27


















            • Thank you for your advice. Will have this in mind. Atm, this is only for personal use combining several commands in a small script.

              – Miro
              Jul 30 at 12:10











            • that's cool. i have no objection to you doing whatever you want for your own needs or education....but that answer combining the output of dig ... |awk ... with the echo statement just irked me. it's bad coding style and it's teaching bad habits.

              – cas
              Jul 30 at 12:27

















            Thank you for your advice. Will have this in mind. Atm, this is only for personal use combining several commands in a small script.

            – Miro
            Jul 30 at 12:10





            Thank you for your advice. Will have this in mind. Atm, this is only for personal use combining several commands in a small script.

            – Miro
            Jul 30 at 12:10













            that's cool. i have no objection to you doing whatever you want for your own needs or education....but that answer combining the output of dig ... |awk ... with the echo statement just irked me. it's bad coding style and it's teaching bad habits.

            – cas
            Jul 30 at 12:27






            that's cool. i have no objection to you doing whatever you want for your own needs or education....but that answer combining the output of dig ... |awk ... with the echo statement just irked me. it's bad coding style and it's teaching bad habits.

            – cas
            Jul 30 at 12:27












            1














            cmd=$(dig soa "$1" +short | awk 'print $3'; echo -n <----------;)

            echo "-------------------------- SOA --------------------------------"
            echo " "
            echo -n " ---------> ";echo $cmd





            share|improve this answer

























            • Thanks. This is indeed something that I was looking for.

              – Miro
              Jul 30 at 12:11















            1














            cmd=$(dig soa "$1" +short | awk 'print $3'; echo -n <----------;)

            echo "-------------------------- SOA --------------------------------"
            echo " "
            echo -n " ---------> ";echo $cmd





            share|improve this answer

























            • Thanks. This is indeed something that I was looking for.

              – Miro
              Jul 30 at 12:11













            1












            1








            1







            cmd=$(dig soa "$1" +short | awk 'print $3'; echo -n <----------;)

            echo "-------------------------- SOA --------------------------------"
            echo " "
            echo -n " ---------> ";echo $cmd





            share|improve this answer













            cmd=$(dig soa "$1" +short | awk 'print $3'; echo -n <----------;)

            echo "-------------------------- SOA --------------------------------"
            echo " "
            echo -n " ---------> ";echo $cmd






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Jul 30 at 11:42









            Rasool ZiafatyRasool Ziafaty

            1249 bronze badges




            1249 bronze badges















            • Thanks. This is indeed something that I was looking for.

              – Miro
              Jul 30 at 12:11

















            • Thanks. This is indeed something that I was looking for.

              – Miro
              Jul 30 at 12:11
















            Thanks. This is indeed something that I was looking for.

            – Miro
            Jul 30 at 12:11





            Thanks. This is indeed something that I was looking for.

            – Miro
            Jul 30 at 12:11











            -1














            I don't have dig so used echo in it's place for this example:



            $ echo '2019072905' | awk '
            BEGIN d=sprintf("%15s",""); gsub(/ /,"-",d); print d d, "SOA", d d ORS
            printf "%*s> %s <%sn", 2*length(d)-length($0)/2+1, d, $0, d
            '
            ------------------------------ SOA ------------------------------

            ---------------> 2019072905 <---------------

            $ echo '201' | awk '
            BEGIN d=sprintf("%15s",""); gsub(/ /,"-",d); print d d, "SOA", d d ORS
            printf "%*s> %s <%sn", 2*length(d)-length($0)/2+1, d, $0, d
            '
            ------------------------------ SOA ------------------------------

            ---------------> 201 <---------------

            $ echo '12345672019072905' | awk '
            BEGIN d=sprintf("%15s",""); gsub(/ /,"-",d); print d d, "SOA", d d ORS
            printf "%*s> %s <%sn", 2*length(d)-length($0)/2+1, d, $0, d
            '
            ------------------------------ SOA ------------------------------

            ---------------> 12345672019072905 <---------------





            share|improve this answer





























              -1














              I don't have dig so used echo in it's place for this example:



              $ echo '2019072905' | awk '
              BEGIN d=sprintf("%15s",""); gsub(/ /,"-",d); print d d, "SOA", d d ORS
              printf "%*s> %s <%sn", 2*length(d)-length($0)/2+1, d, $0, d
              '
              ------------------------------ SOA ------------------------------

              ---------------> 2019072905 <---------------

              $ echo '201' | awk '
              BEGIN d=sprintf("%15s",""); gsub(/ /,"-",d); print d d, "SOA", d d ORS
              printf "%*s> %s <%sn", 2*length(d)-length($0)/2+1, d, $0, d
              '
              ------------------------------ SOA ------------------------------

              ---------------> 201 <---------------

              $ echo '12345672019072905' | awk '
              BEGIN d=sprintf("%15s",""); gsub(/ /,"-",d); print d d, "SOA", d d ORS
              printf "%*s> %s <%sn", 2*length(d)-length($0)/2+1, d, $0, d
              '
              ------------------------------ SOA ------------------------------

              ---------------> 12345672019072905 <---------------





              share|improve this answer



























                -1












                -1








                -1







                I don't have dig so used echo in it's place for this example:



                $ echo '2019072905' | awk '
                BEGIN d=sprintf("%15s",""); gsub(/ /,"-",d); print d d, "SOA", d d ORS
                printf "%*s> %s <%sn", 2*length(d)-length($0)/2+1, d, $0, d
                '
                ------------------------------ SOA ------------------------------

                ---------------> 2019072905 <---------------

                $ echo '201' | awk '
                BEGIN d=sprintf("%15s",""); gsub(/ /,"-",d); print d d, "SOA", d d ORS
                printf "%*s> %s <%sn", 2*length(d)-length($0)/2+1, d, $0, d
                '
                ------------------------------ SOA ------------------------------

                ---------------> 201 <---------------

                $ echo '12345672019072905' | awk '
                BEGIN d=sprintf("%15s",""); gsub(/ /,"-",d); print d d, "SOA", d d ORS
                printf "%*s> %s <%sn", 2*length(d)-length($0)/2+1, d, $0, d
                '
                ------------------------------ SOA ------------------------------

                ---------------> 12345672019072905 <---------------





                share|improve this answer













                I don't have dig so used echo in it's place for this example:



                $ echo '2019072905' | awk '
                BEGIN d=sprintf("%15s",""); gsub(/ /,"-",d); print d d, "SOA", d d ORS
                printf "%*s> %s <%sn", 2*length(d)-length($0)/2+1, d, $0, d
                '
                ------------------------------ SOA ------------------------------

                ---------------> 2019072905 <---------------

                $ echo '201' | awk '
                BEGIN d=sprintf("%15s",""); gsub(/ /,"-",d); print d d, "SOA", d d ORS
                printf "%*s> %s <%sn", 2*length(d)-length($0)/2+1, d, $0, d
                '
                ------------------------------ SOA ------------------------------

                ---------------> 201 <---------------

                $ echo '12345672019072905' | awk '
                BEGIN d=sprintf("%15s",""); gsub(/ /,"-",d); print d d, "SOA", d d ORS
                printf "%*s> %s <%sn", 2*length(d)-length($0)/2+1, d, $0, d
                '
                ------------------------------ SOA ------------------------------

                ---------------> 12345672019072905 <---------------






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Jul 31 at 5:32









                Ed MortonEd Morton

                1,2464 silver badges9 bronze badges




                1,2464 silver badges9 bronze badges






























                    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.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f532938%2fnext-command-output-on-the-same-line-bash-script%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

                    Get product attribute by attribute group code in magento 2get product attribute by product attribute group in magento 2Magento 2 Log Bundle Product Data in List Page?How to get all product attribute of a attribute group of Default attribute set?Magento 2.1 Create a filter in the product grid by new attributeMagento 2 : Get Product Attribute values By GroupMagento 2 How to get all existing values for one attributeMagento 2 get custom attribute of a single product inside a pluginMagento 2.3 How to get all the Multi Source Inventory (MSI) locations collection in custom module?Magento2: how to develop rest API to get new productsGet product attribute by attribute group code ( [attribute_group_code] ) in magento 2

                    Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

                    Magento 2.3: How do i solve this, Not registered handle, on custom form?How can i rewrite TierPrice Block in Magento2magento 2 captcha not rendering if I override layout xmlmain.CRITICAL: Plugin class doesn't existMagento 2 : Problem while adding custom button order view page?Magento 2.2.5: Overriding Admin Controller sales/orderMagento 2.2.5: Add, Update and Delete existing products Custom OptionsMagento 2.3 : File Upload issue in UI Component FormMagento2 Not registered handleHow to configured Form Builder Js in my custom magento 2.3.0 module?Magento 2.3. How to create image upload field in an admin form