Extract specific directories with all subdirectories from a tar file

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











up vote
0
down vote

favorite












I know how to extract single file from a tarball, although now I have 500 GB tar file without any compression, just a plain tar and I would like to extract specifically 3 directories, with such structure:



dir1/subDir1/
dir2/subDir2/
dir3/subDir3/subSubDir3/


There are many subdirectories inside each of those and real many files. I wish to simply extract everything inside of those.



I am curious as to how to do this, without having to extract the whole tarball.







share|improve this question
























    up vote
    0
    down vote

    favorite












    I know how to extract single file from a tarball, although now I have 500 GB tar file without any compression, just a plain tar and I would like to extract specifically 3 directories, with such structure:



    dir1/subDir1/
    dir2/subDir2/
    dir3/subDir3/subSubDir3/


    There are many subdirectories inside each of those and real many files. I wish to simply extract everything inside of those.



    I am curious as to how to do this, without having to extract the whole tarball.







    share|improve this question






















      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I know how to extract single file from a tarball, although now I have 500 GB tar file without any compression, just a plain tar and I would like to extract specifically 3 directories, with such structure:



      dir1/subDir1/
      dir2/subDir2/
      dir3/subDir3/subSubDir3/


      There are many subdirectories inside each of those and real many files. I wish to simply extract everything inside of those.



      I am curious as to how to do this, without having to extract the whole tarball.







      share|improve this question












      I know how to extract single file from a tarball, although now I have 500 GB tar file without any compression, just a plain tar and I would like to extract specifically 3 directories, with such structure:



      dir1/subDir1/
      dir2/subDir2/
      dir3/subDir3/subSubDir3/


      There are many subdirectories inside each of those and real many files. I wish to simply extract everything inside of those.



      I am curious as to how to do this, without having to extract the whole tarball.









      share|improve this question











      share|improve this question




      share|improve this question










      asked Oct 14 '17 at 11:36









      Vlastimil

      6,4761148121




      6,4761148121




















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          3
          down vote



          accepted










          tar extracts directories like files, see the man page for more info.



          # -v; verbose parameter is rather obstructive
          # in case of thousands and thousands of files

          tar -xf archive.tar directory/





          share|improve this answer





























            up vote
            1
            down vote













            You can use the --strip-components=n option.



            tar -xvf archive.tar --strip-components=4



            --strip-components=NUMBER



            strip NUMBER leading components from file names on extraction






            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%2f398095%2fextract-specific-directories-with-all-subdirectories-from-a-tar-file%23new-answer', 'question_page');

              );

              Post as a guest






























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes








              up vote
              3
              down vote



              accepted










              tar extracts directories like files, see the man page for more info.



              # -v; verbose parameter is rather obstructive
              # in case of thousands and thousands of files

              tar -xf archive.tar directory/





              share|improve this answer


























                up vote
                3
                down vote



                accepted










                tar extracts directories like files, see the man page for more info.



                # -v; verbose parameter is rather obstructive
                # in case of thousands and thousands of files

                tar -xf archive.tar directory/





                share|improve this answer
























                  up vote
                  3
                  down vote



                  accepted







                  up vote
                  3
                  down vote



                  accepted






                  tar extracts directories like files, see the man page for more info.



                  # -v; verbose parameter is rather obstructive
                  # in case of thousands and thousands of files

                  tar -xf archive.tar directory/





                  share|improve this answer














                  tar extracts directories like files, see the man page for more info.



                  # -v; verbose parameter is rather obstructive
                  # in case of thousands and thousands of files

                  tar -xf archive.tar directory/






                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Oct 14 '17 at 21:52









                  Hunter.S.Thompson

                  4,56431334




                  4,56431334










                  answered Oct 14 '17 at 12:28









                  jdwolf

                  2,392116




                  2,392116






















                      up vote
                      1
                      down vote













                      You can use the --strip-components=n option.



                      tar -xvf archive.tar --strip-components=4



                      --strip-components=NUMBER



                      strip NUMBER leading components from file names on extraction






                      share|improve this answer
























                        up vote
                        1
                        down vote













                        You can use the --strip-components=n option.



                        tar -xvf archive.tar --strip-components=4



                        --strip-components=NUMBER



                        strip NUMBER leading components from file names on extraction






                        share|improve this answer






















                          up vote
                          1
                          down vote










                          up vote
                          1
                          down vote









                          You can use the --strip-components=n option.



                          tar -xvf archive.tar --strip-components=4



                          --strip-components=NUMBER



                          strip NUMBER leading components from file names on extraction






                          share|improve this answer












                          You can use the --strip-components=n option.



                          tar -xvf archive.tar --strip-components=4



                          --strip-components=NUMBER



                          strip NUMBER leading components from file names on extraction







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Oct 14 '17 at 12:51









                          Hunter.S.Thompson

                          4,56431334




                          4,56431334



























                               

                              draft saved


                              draft discarded















































                               


                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function ()
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f398095%2fextract-specific-directories-with-all-subdirectories-from-a-tar-file%23new-answer', 'question_page');

                              );

                              Post as a guest













































































                              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?