How to download an archive and extract it without saving the archive to disk?

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












51















I'd like to download, and extract an archive under a given directory. Here is how I've been doing it so far:



wget http://downloads.mysql.com/source/dbt2-0.37.50.3.tar.gz
tar zxf dbt2-0.37.50.3.tar.gz
mv dbt2-0.37.50.3 dbt2


I'd like instead to download and extract the archive on the fly, without having the tar.gz written to the disk. I think this is possible by piping the output of wget to tar, and giving tar a target, but in practice I don't know how to put the pieces together.










share|improve this question




























    51















    I'd like to download, and extract an archive under a given directory. Here is how I've been doing it so far:



    wget http://downloads.mysql.com/source/dbt2-0.37.50.3.tar.gz
    tar zxf dbt2-0.37.50.3.tar.gz
    mv dbt2-0.37.50.3 dbt2


    I'd like instead to download and extract the archive on the fly, without having the tar.gz written to the disk. I think this is possible by piping the output of wget to tar, and giving tar a target, but in practice I don't know how to put the pieces together.










    share|improve this question


























      51












      51








      51


      13






      I'd like to download, and extract an archive under a given directory. Here is how I've been doing it so far:



      wget http://downloads.mysql.com/source/dbt2-0.37.50.3.tar.gz
      tar zxf dbt2-0.37.50.3.tar.gz
      mv dbt2-0.37.50.3 dbt2


      I'd like instead to download and extract the archive on the fly, without having the tar.gz written to the disk. I think this is possible by piping the output of wget to tar, and giving tar a target, but in practice I don't know how to put the pieces together.










      share|improve this question
















      I'd like to download, and extract an archive under a given directory. Here is how I've been doing it so far:



      wget http://downloads.mysql.com/source/dbt2-0.37.50.3.tar.gz
      tar zxf dbt2-0.37.50.3.tar.gz
      mv dbt2-0.37.50.3 dbt2


      I'd like instead to download and extract the archive on the fly, without having the tar.gz written to the disk. I think this is possible by piping the output of wget to tar, and giving tar a target, but in practice I don't know how to put the pieces together.







      shell pipe tar wget






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Aug 1 '13 at 23:31









      Gilles

      540k12810941608




      540k12810941608










      asked Aug 1 '13 at 14:19









      BenjaminBenjamin

      1,30741935




      1,30741935




















          3 Answers
          3






          active

          oldest

          votes


















          86














          You can do it by telling wget to output its payload to stdout (with flag -O-) and supress its own output (with flag -q):



          wget -qO- your_link_here | tar xvz -


          To specify a target directory:



          wget -qO- your_link_here | tar xvz - -C /target/directory


          Update



          If you happen to have GNU tar



          wget -qO- your_link_here | tar --transform 's/^dbt2-0.37.50.3/dbt2/' -xvz


          should allow you to do it all in one step.



          -q quiet



          -O - output to stdout






          share|improve this answer

























          • To specified path should be: wget -qO- your_link_here | tar xvz - -C /target/directory

            – Marslo
            Sep 12 '18 at 12:10


















          11














          This oneliner does the trick:



          tar xvzf -C /tmp/ < <(wget -q -O - http://foo.com/myfile.tar.gz)


          short explanation:
          the right side in the parenthesis is executed first (-q tells wget to do it quietly, -O - is used to write the output to stdout).



          Then we create a named pipe using the process substitution operator from Bash <( to create a named pipe.
          This way we create a temporary file descriptor and then direct the contents of that descriptor to tar using the < file redirection operator.






          share|improve this answer
































            7














            Another option is to use curl which writes to stdout by default:



            curl -s some_url | tar xvz -C /tmp





            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%2f85194%2fhow-to-download-an-archive-and-extract-it-without-saving-the-archive-to-disk%23new-answer', 'question_page');

              );

              Post as a guest















              Required, but never shown

























              3 Answers
              3






              active

              oldest

              votes








              3 Answers
              3






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              86














              You can do it by telling wget to output its payload to stdout (with flag -O-) and supress its own output (with flag -q):



              wget -qO- your_link_here | tar xvz -


              To specify a target directory:



              wget -qO- your_link_here | tar xvz - -C /target/directory


              Update



              If you happen to have GNU tar



              wget -qO- your_link_here | tar --transform 's/^dbt2-0.37.50.3/dbt2/' -xvz


              should allow you to do it all in one step.



              -q quiet



              -O - output to stdout






              share|improve this answer

























              • To specified path should be: wget -qO- your_link_here | tar xvz - -C /target/directory

                – Marslo
                Sep 12 '18 at 12:10















              86














              You can do it by telling wget to output its payload to stdout (with flag -O-) and supress its own output (with flag -q):



              wget -qO- your_link_here | tar xvz -


              To specify a target directory:



              wget -qO- your_link_here | tar xvz - -C /target/directory


              Update



              If you happen to have GNU tar



              wget -qO- your_link_here | tar --transform 's/^dbt2-0.37.50.3/dbt2/' -xvz


              should allow you to do it all in one step.



              -q quiet



              -O - output to stdout






              share|improve this answer

























              • To specified path should be: wget -qO- your_link_here | tar xvz - -C /target/directory

                – Marslo
                Sep 12 '18 at 12:10













              86












              86








              86







              You can do it by telling wget to output its payload to stdout (with flag -O-) and supress its own output (with flag -q):



              wget -qO- your_link_here | tar xvz -


              To specify a target directory:



              wget -qO- your_link_here | tar xvz - -C /target/directory


              Update



              If you happen to have GNU tar



              wget -qO- your_link_here | tar --transform 's/^dbt2-0.37.50.3/dbt2/' -xvz


              should allow you to do it all in one step.



              -q quiet



              -O - output to stdout






              share|improve this answer















              You can do it by telling wget to output its payload to stdout (with flag -O-) and supress its own output (with flag -q):



              wget -qO- your_link_here | tar xvz -


              To specify a target directory:



              wget -qO- your_link_here | tar xvz - -C /target/directory


              Update



              If you happen to have GNU tar



              wget -qO- your_link_here | tar --transform 's/^dbt2-0.37.50.3/dbt2/' -xvz


              should allow you to do it all in one step.



              -q quiet



              -O - output to stdout







              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited Feb 10 at 0:49









              MrE

              253310




              253310










              answered Aug 1 '13 at 14:23









              Joseph R.Joseph R.

              28.5k375116




              28.5k375116












              • To specified path should be: wget -qO- your_link_here | tar xvz - -C /target/directory

                – Marslo
                Sep 12 '18 at 12:10

















              • To specified path should be: wget -qO- your_link_here | tar xvz - -C /target/directory

                – Marslo
                Sep 12 '18 at 12:10
















              To specified path should be: wget -qO- your_link_here | tar xvz - -C /target/directory

              – Marslo
              Sep 12 '18 at 12:10





              To specified path should be: wget -qO- your_link_here | tar xvz - -C /target/directory

              – Marslo
              Sep 12 '18 at 12:10













              11














              This oneliner does the trick:



              tar xvzf -C /tmp/ < <(wget -q -O - http://foo.com/myfile.tar.gz)


              short explanation:
              the right side in the parenthesis is executed first (-q tells wget to do it quietly, -O - is used to write the output to stdout).



              Then we create a named pipe using the process substitution operator from Bash <( to create a named pipe.
              This way we create a temporary file descriptor and then direct the contents of that descriptor to tar using the < file redirection operator.






              share|improve this answer





























                11














                This oneliner does the trick:



                tar xvzf -C /tmp/ < <(wget -q -O - http://foo.com/myfile.tar.gz)


                short explanation:
                the right side in the parenthesis is executed first (-q tells wget to do it quietly, -O - is used to write the output to stdout).



                Then we create a named pipe using the process substitution operator from Bash <( to create a named pipe.
                This way we create a temporary file descriptor and then direct the contents of that descriptor to tar using the < file redirection operator.






                share|improve this answer



























                  11












                  11








                  11







                  This oneliner does the trick:



                  tar xvzf -C /tmp/ < <(wget -q -O - http://foo.com/myfile.tar.gz)


                  short explanation:
                  the right side in the parenthesis is executed first (-q tells wget to do it quietly, -O - is used to write the output to stdout).



                  Then we create a named pipe using the process substitution operator from Bash <( to create a named pipe.
                  This way we create a temporary file descriptor and then direct the contents of that descriptor to tar using the < file redirection operator.






                  share|improve this answer















                  This oneliner does the trick:



                  tar xvzf -C /tmp/ < <(wget -q -O - http://foo.com/myfile.tar.gz)


                  short explanation:
                  the right side in the parenthesis is executed first (-q tells wget to do it quietly, -O - is used to write the output to stdout).



                  Then we create a named pipe using the process substitution operator from Bash <( to create a named pipe.
                  This way we create a temporary file descriptor and then direct the contents of that descriptor to tar using the < file redirection operator.







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Aug 25 '14 at 19:57









                  Daniel Serodio

                  7181714




                  7181714










                  answered Aug 1 '13 at 14:49









                  ItsMeItsMe

                  1963




                  1963





















                      7














                      Another option is to use curl which writes to stdout by default:



                      curl -s some_url | tar xvz -C /tmp





                      share|improve this answer



























                        7














                        Another option is to use curl which writes to stdout by default:



                        curl -s some_url | tar xvz -C /tmp





                        share|improve this answer

























                          7












                          7








                          7







                          Another option is to use curl which writes to stdout by default:



                          curl -s some_url | tar xvz -C /tmp





                          share|improve this answer













                          Another option is to use curl which writes to stdout by default:



                          curl -s some_url | tar xvz -C /tmp






                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Mar 12 '18 at 21:46









                          Zlemini Zlemini

                          20326




                          20326



























                              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%2f85194%2fhow-to-download-an-archive-and-extract-it-without-saving-the-archive-to-disk%23new-answer', 'question_page');

                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown






                              Popular posts from this blog

                              How to check contact read email or not when send email to Individual?

                              Displaying single band from multi-band raster using QGIS

                              How many registers does an x86_64 CPU actually have?