How could I untar many tar files seperately with one command?Why *not* parse `ls` (and what to do...

What precisely does the commonly reported network hash rate refer to?

Python implementation of atoi

Bit floating sequence

Why did Tony's Arc Reactor do this?

Bacteria vats to generate edible biomass, require intermediary species?

How invisible hand adjusts stock prices if company is listed on multiple exchanges, under multiple currencies, and one of the currencies plunges?

Why would an airport be depicted with symbology for runways longer than 8,069 feet even though it is reported on the sectional as 7,200 feet?

Why are UK MPs allowed to abstain (but it counts as a no)?

What happens when a file that is 100% paged in to the page cache gets modified by another process

Can taking my 1-week-old on a 6-7 hours journey in the car lead to medical complications?

Leaving the USA for 10 yrs when you have asylum

How can I hint that my character isn't real?

Why is it that I have to play this note on the piano as A sharp?

After a few interviews, What should I do after told to wait?

How do English-speaking kids loudly request something?

How to finish my PhD?

I multiply the source, you (probably) multiply the output!

Was Robin Hood's point of view ethically sound?

Are professors obligated to accept supervisory role? If not, how does it work?

Short story: Interstellar inspector senses "off" nature of planet hiding aggressive culture

Is there a "right" way to interpret a novel, if not, how do we make sure our novel is interpreted correctly?

Why is Sojdlg123aljg a common password?

Would a character take damage when surrounded by, but not in, flames?

Why does 8 bit truecolor use only 2 bits for blue?



How could I untar many tar files seperately with one command?


Why *not* parse `ls` (and what to do instead)?remove files after insertion into tarballtar append to file in archivetar extract into directory with same base name?create flat tar archive: ignoring all parents when adding foldersUnable to untar file after tar errorUntar subfolders with initial folder's content in linuxExtract specific directories with all subdirectories from a tar fileRecursive UNTAR / UNZIP






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







0















I have many tar files like this: aa.tar, bb.tar, cc.tar, ....



I would like to untar them to their own directories such as aa/, bb/, cc/ ...



I tried this:



ls | xargs -n1 -I {} tar -xvf {} -C `basename {} .tar`


which does not work. It seems that the {} cannot be used as both whole tar file name and its file name without .tar.



How could I make it work?










share|improve this question







New contributor



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




























    0















    I have many tar files like this: aa.tar, bb.tar, cc.tar, ....



    I would like to untar them to their own directories such as aa/, bb/, cc/ ...



    I tried this:



    ls | xargs -n1 -I {} tar -xvf {} -C `basename {} .tar`


    which does not work. It seems that the {} cannot be used as both whole tar file name and its file name without .tar.



    How could I make it work?










    share|improve this question







    New contributor



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
























      0












      0








      0








      I have many tar files like this: aa.tar, bb.tar, cc.tar, ....



      I would like to untar them to their own directories such as aa/, bb/, cc/ ...



      I tried this:



      ls | xargs -n1 -I {} tar -xvf {} -C `basename {} .tar`


      which does not work. It seems that the {} cannot be used as both whole tar file name and its file name without .tar.



      How could I make it work?










      share|improve this question







      New contributor



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











      I have many tar files like this: aa.tar, bb.tar, cc.tar, ....



      I would like to untar them to their own directories such as aa/, bb/, cc/ ...



      I tried this:



      ls | xargs -n1 -I {} tar -xvf {} -C `basename {} .tar`


      which does not work. It seems that the {} cannot be used as both whole tar file name and its file name without .tar.



      How could I make it work?







      shell tar xargs






      share|improve this question







      New contributor



      coin cheung 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



      coin cheung 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






      New contributor



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








      asked 11 mins ago









      coin cheungcoin cheung

      1




      1




      New contributor



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




      New contributor




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



























          1 Answer
          1






          active

          oldest

          votes


















          0
















          Use a for loop, there's no need for xargs. e.g.



          for t in *.tar ; do
          bn="$(basename "$t" .tar)"
          mkdir -p "$bn"
          tar -xvf "$t" -C "$bn"
          done


          See also: Why not parse ls (and what to do instead)?





          share




























            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/4.0/"u003ecc by-sa 4.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
            });


            }
            });







            coin cheung 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%2f539570%2fhow-could-i-untar-many-tar-files-seperately-with-one-command%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0
















            Use a for loop, there's no need for xargs. e.g.



            for t in *.tar ; do
            bn="$(basename "$t" .tar)"
            mkdir -p "$bn"
            tar -xvf "$t" -C "$bn"
            done


            See also: Why not parse ls (and what to do instead)?





            share






























              0
















              Use a for loop, there's no need for xargs. e.g.



              for t in *.tar ; do
              bn="$(basename "$t" .tar)"
              mkdir -p "$bn"
              tar -xvf "$t" -C "$bn"
              done


              See also: Why not parse ls (and what to do instead)?





              share




























                0














                0










                0









                Use a for loop, there's no need for xargs. e.g.



                for t in *.tar ; do
                bn="$(basename "$t" .tar)"
                mkdir -p "$bn"
                tar -xvf "$t" -C "$bn"
                done


                See also: Why not parse ls (and what to do instead)?





                share













                Use a for loop, there's no need for xargs. e.g.



                for t in *.tar ; do
                bn="$(basename "$t" .tar)"
                mkdir -p "$bn"
                tar -xvf "$t" -C "$bn"
                done


                See also: Why not parse ls (and what to do instead)?






                share











                share


                share










                answered 2 mins ago









                cascas

                42.8k4 gold badges62 silver badges112 bronze badges




                42.8k4 gold badges62 silver badges112 bronze badges


























                    coin cheung is a new contributor. Be nice, and check out our Code of Conduct.










                    draft saved

                    draft discarded

















                    coin cheung is a new contributor. Be nice, and check out our Code of Conduct.













                    coin cheung is a new contributor. Be nice, and check out our Code of Conduct.












                    coin cheung 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%2f539570%2fhow-could-i-untar-many-tar-files-seperately-with-one-command%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

                    Taj Mahal Inhaltsverzeichnis Aufbau | Geschichte | 350-Jahr-Feier | Heutige Bedeutung | Siehe auch |...

                    Baia Sprie Cuprins Etimologie | Istorie | Demografie | Politică și administrație | Arii naturale...

                    Ciclooctatetraenă Vezi și | Bibliografie | Meniu de navigare637866text4148569-500570979m