How to concatanate the result of two linux commands?

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











up vote
1
down vote

favorite












Is there an easy way to concatenate the result of two linux commands, in one line? (i.e without using variables)



I pull the local outdoor temperature from a nearby weather station. The result today is:
5.2
I simply want to add the units, so result should look like this:
5.2°C



An example command, that almost gives me what I want is:
wget -q -O- "http://meteocentre.com/montreal/home_e.html" | grep -oP '(?<=Tn= ).*(?=&deg)' ; printf "°Cn"










share|improve this question

























    up vote
    1
    down vote

    favorite












    Is there an easy way to concatenate the result of two linux commands, in one line? (i.e without using variables)



    I pull the local outdoor temperature from a nearby weather station. The result today is:
    5.2
    I simply want to add the units, so result should look like this:
    5.2°C



    An example command, that almost gives me what I want is:
    wget -q -O- "http://meteocentre.com/montreal/home_e.html" | grep -oP '(?<=Tn= ).*(?=&deg)' ; printf "°Cn"










    share|improve this question























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      Is there an easy way to concatenate the result of two linux commands, in one line? (i.e without using variables)



      I pull the local outdoor temperature from a nearby weather station. The result today is:
      5.2
      I simply want to add the units, so result should look like this:
      5.2°C



      An example command, that almost gives me what I want is:
      wget -q -O- "http://meteocentre.com/montreal/home_e.html" | grep -oP '(?<=Tn= ).*(?=&deg)' ; printf "°Cn"










      share|improve this question













      Is there an easy way to concatenate the result of two linux commands, in one line? (i.e without using variables)



      I pull the local outdoor temperature from a nearby weather station. The result today is:
      5.2
      I simply want to add the units, so result should look like this:
      5.2°C



      An example command, that almost gives me what I want is:
      wget -q -O- "http://meteocentre.com/montreal/home_e.html" | grep -oP '(?<=Tn= ).*(?=&deg)' ; printf "°Cn"







      bash awk sed grep tr






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 1 hour ago









      Mtl Dev

      229311




      229311




















          3 Answers
          3






          active

          oldest

          votes

















          up vote
          4
          down vote



          accepted










          Or do it inside-out:



          printf "%s°Cn" "$(wget -q -O- "http://meteocentre.com/montreal/home_e.html" | grep -oP '(?<=Tn= ).*(?=&deg)')"


          So that the results from wget...|grep... are collected as a command-substitution and inserted into the %s in the printf.






          share|improve this answer



























            up vote
            2
            down vote













            echo, for example, just prints all the arguments you give it. You can use command substitution to turn the output of a command into a string.



            echo $(wget -q -O- "http://meteocentre.com/montreal/home_e.html" | grep -oP '(?<=Tn= ).*(?=&deg)') °C





            share|improve this answer



























              up vote
              2
              down vote













              Delete the carriage return at the end of wget’s output:



              wget -q -O- "http://meteocentre.com/montreal/home_e.html" | grep -oP '(?<=Tn= ).*(?=&deg)' | tr -d 'n' ; printf "°Cn"





              share|improve this answer




















                Your Answer







                StackExchange.ready(function()
                var channelOptions =
                tags: "".split(" "),
                id: "106"
                ;
                initTagRenderer("".split(" "), "".split(" "), channelOptions);

                StackExchange.using("externalEditor", function()
                // Have to fire editor after snippets, if snippets enabled
                if (StackExchange.settings.snippets.snippetsEnabled)
                StackExchange.using("snippets", function()
                createEditor();
                );

                else
                createEditor();

                );

                function createEditor()
                StackExchange.prepareEditor(
                heartbeatType: 'answer',
                convertImagesToLinks: false,
                noModals: false,
                showLowRepImageUploadWarning: true,
                reputationToPostImages: null,
                bindNavPrevention: true,
                postfix: "",
                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%2f475854%2fhow-to-concatanate-the-result-of-two-linux-commands%23new-answer', 'question_page');

                );

                Post as a guest






























                3 Answers
                3






                active

                oldest

                votes








                3 Answers
                3






                active

                oldest

                votes









                active

                oldest

                votes






                active

                oldest

                votes








                up vote
                4
                down vote



                accepted










                Or do it inside-out:



                printf "%s°Cn" "$(wget -q -O- "http://meteocentre.com/montreal/home_e.html" | grep -oP '(?<=Tn= ).*(?=&deg)')"


                So that the results from wget...|grep... are collected as a command-substitution and inserted into the %s in the printf.






                share|improve this answer
























                  up vote
                  4
                  down vote



                  accepted










                  Or do it inside-out:



                  printf "%s°Cn" "$(wget -q -O- "http://meteocentre.com/montreal/home_e.html" | grep -oP '(?<=Tn= ).*(?=&deg)')"


                  So that the results from wget...|grep... are collected as a command-substitution and inserted into the %s in the printf.






                  share|improve this answer






















                    up vote
                    4
                    down vote



                    accepted







                    up vote
                    4
                    down vote



                    accepted






                    Or do it inside-out:



                    printf "%s°Cn" "$(wget -q -O- "http://meteocentre.com/montreal/home_e.html" | grep -oP '(?<=Tn= ).*(?=&deg)')"


                    So that the results from wget...|grep... are collected as a command-substitution and inserted into the %s in the printf.






                    share|improve this answer












                    Or do it inside-out:



                    printf "%s°Cn" "$(wget -q -O- "http://meteocentre.com/montreal/home_e.html" | grep -oP '(?<=Tn= ).*(?=&deg)')"


                    So that the results from wget...|grep... are collected as a command-substitution and inserted into the %s in the printf.







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered 1 hour ago









                    Jeff Schaller

                    34k851113




                    34k851113






















                        up vote
                        2
                        down vote













                        echo, for example, just prints all the arguments you give it. You can use command substitution to turn the output of a command into a string.



                        echo $(wget -q -O- "http://meteocentre.com/montreal/home_e.html" | grep -oP '(?<=Tn= ).*(?=&deg)') °C





                        share|improve this answer
























                          up vote
                          2
                          down vote













                          echo, for example, just prints all the arguments you give it. You can use command substitution to turn the output of a command into a string.



                          echo $(wget -q -O- "http://meteocentre.com/montreal/home_e.html" | grep -oP '(?<=Tn= ).*(?=&deg)') °C





                          share|improve this answer






















                            up vote
                            2
                            down vote










                            up vote
                            2
                            down vote









                            echo, for example, just prints all the arguments you give it. You can use command substitution to turn the output of a command into a string.



                            echo $(wget -q -O- "http://meteocentre.com/montreal/home_e.html" | grep -oP '(?<=Tn= ).*(?=&deg)') °C





                            share|improve this answer












                            echo, for example, just prints all the arguments you give it. You can use command substitution to turn the output of a command into a string.



                            echo $(wget -q -O- "http://meteocentre.com/montreal/home_e.html" | grep -oP '(?<=Tn= ).*(?=&deg)') °C






                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered 1 hour ago









                            choroba

                            25.1k44269




                            25.1k44269




















                                up vote
                                2
                                down vote













                                Delete the carriage return at the end of wget’s output:



                                wget -q -O- "http://meteocentre.com/montreal/home_e.html" | grep -oP '(?<=Tn= ).*(?=&deg)' | tr -d 'n' ; printf "°Cn"





                                share|improve this answer
























                                  up vote
                                  2
                                  down vote













                                  Delete the carriage return at the end of wget’s output:



                                  wget -q -O- "http://meteocentre.com/montreal/home_e.html" | grep -oP '(?<=Tn= ).*(?=&deg)' | tr -d 'n' ; printf "°Cn"





                                  share|improve this answer






















                                    up vote
                                    2
                                    down vote










                                    up vote
                                    2
                                    down vote









                                    Delete the carriage return at the end of wget’s output:



                                    wget -q -O- "http://meteocentre.com/montreal/home_e.html" | grep -oP '(?<=Tn= ).*(?=&deg)' | tr -d 'n' ; printf "°Cn"





                                    share|improve this answer












                                    Delete the carriage return at the end of wget’s output:



                                    wget -q -O- "http://meteocentre.com/montreal/home_e.html" | grep -oP '(?<=Tn= ).*(?=&deg)' | tr -d 'n' ; printf "°Cn"






                                    share|improve this answer












                                    share|improve this answer



                                    share|improve this answer










                                    answered 1 hour ago









                                    Stephen Kitt

                                    151k23335402




                                    151k23335402



























                                         

                                        draft saved


                                        draft discarded















































                                         


                                        draft saved


                                        draft discarded














                                        StackExchange.ready(
                                        function ()
                                        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f475854%2fhow-to-concatanate-the-result-of-two-linux-commands%23new-answer', 'question_page');

                                        );

                                        Post as a guest













































































                                        Comments

                                        Popular posts from this blog

                                        Long meetings (6-7 hours a day): Being “babysat” by supervisor

                                        Is the Concept of Multiple Fantasy Races Scientifically Flawed? [closed]

                                        Confectionery