How do I delete a single file from a tar.gz archive












11















I have a huge tarbell archive with an excessively large or corrupt error_log that causes the archive to hang when attempting to extract it. Is there a way to remove this from the archive before unzipping or extract the archive without extracting that specific file on Mac OS X terminal?



I found this post on how to efficiently-remove-files-from-large-tgz however, I tried the --delete flag, but received this error:



tar: Option --delete is not supported


Is there a way to:




  1. remove the file from the archive without unzipping it?

  2. extract the archive but exclude the file?










share|improve this question

























  • Which version of tar are you using? If its outdated then try to update to the latest version and check the man page if tar supports --delete as an option.

    – Santosh A
    Jun 21 '15 at 8:21






  • 1





    The --delete option is specific to some tar programs (notably the default available under linux). From memory, the default tar under macos does not support that. You'll need to read the man/help file, or obtain a program that supports such functionality. All else failing, unzip the .tar.gz file, extract everything from the archive, delete the unwanted file, and then rebuild the archive.

    – Peter
    Jun 21 '15 at 8:24











  • Santosh and Peter, thank you so much for your responses. Santosh, not sure which version of tar is running on Mac OS x nor how to update it. Peter, thanks too. This isn't an option, since extracting the archive fails due to how large the error_log is.

    – KillerDesigner
    Jun 21 '15 at 15:09
















11















I have a huge tarbell archive with an excessively large or corrupt error_log that causes the archive to hang when attempting to extract it. Is there a way to remove this from the archive before unzipping or extract the archive without extracting that specific file on Mac OS X terminal?



I found this post on how to efficiently-remove-files-from-large-tgz however, I tried the --delete flag, but received this error:



tar: Option --delete is not supported


Is there a way to:




  1. remove the file from the archive without unzipping it?

  2. extract the archive but exclude the file?










share|improve this question

























  • Which version of tar are you using? If its outdated then try to update to the latest version and check the man page if tar supports --delete as an option.

    – Santosh A
    Jun 21 '15 at 8:21






  • 1





    The --delete option is specific to some tar programs (notably the default available under linux). From memory, the default tar under macos does not support that. You'll need to read the man/help file, or obtain a program that supports such functionality. All else failing, unzip the .tar.gz file, extract everything from the archive, delete the unwanted file, and then rebuild the archive.

    – Peter
    Jun 21 '15 at 8:24











  • Santosh and Peter, thank you so much for your responses. Santosh, not sure which version of tar is running on Mac OS x nor how to update it. Peter, thanks too. This isn't an option, since extracting the archive fails due to how large the error_log is.

    – KillerDesigner
    Jun 21 '15 at 15:09














11












11








11








I have a huge tarbell archive with an excessively large or corrupt error_log that causes the archive to hang when attempting to extract it. Is there a way to remove this from the archive before unzipping or extract the archive without extracting that specific file on Mac OS X terminal?



I found this post on how to efficiently-remove-files-from-large-tgz however, I tried the --delete flag, but received this error:



tar: Option --delete is not supported


Is there a way to:




  1. remove the file from the archive without unzipping it?

  2. extract the archive but exclude the file?










share|improve this question
















I have a huge tarbell archive with an excessively large or corrupt error_log that causes the archive to hang when attempting to extract it. Is there a way to remove this from the archive before unzipping or extract the archive without extracting that specific file on Mac OS X terminal?



I found this post on how to efficiently-remove-files-from-large-tgz however, I tried the --delete flag, but received this error:



tar: Option --delete is not supported


Is there a way to:




  1. remove the file from the archive without unzipping it?

  2. extract the archive but exclude the file?







tar gz






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Apr 13 '17 at 12:36









Community

11




11










asked Jun 21 '15 at 8:12









KillerDesignerKillerDesigner

1511214




1511214













  • Which version of tar are you using? If its outdated then try to update to the latest version and check the man page if tar supports --delete as an option.

    – Santosh A
    Jun 21 '15 at 8:21






  • 1





    The --delete option is specific to some tar programs (notably the default available under linux). From memory, the default tar under macos does not support that. You'll need to read the man/help file, or obtain a program that supports such functionality. All else failing, unzip the .tar.gz file, extract everything from the archive, delete the unwanted file, and then rebuild the archive.

    – Peter
    Jun 21 '15 at 8:24











  • Santosh and Peter, thank you so much for your responses. Santosh, not sure which version of tar is running on Mac OS x nor how to update it. Peter, thanks too. This isn't an option, since extracting the archive fails due to how large the error_log is.

    – KillerDesigner
    Jun 21 '15 at 15:09



















  • Which version of tar are you using? If its outdated then try to update to the latest version and check the man page if tar supports --delete as an option.

    – Santosh A
    Jun 21 '15 at 8:21






  • 1





    The --delete option is specific to some tar programs (notably the default available under linux). From memory, the default tar under macos does not support that. You'll need to read the man/help file, or obtain a program that supports such functionality. All else failing, unzip the .tar.gz file, extract everything from the archive, delete the unwanted file, and then rebuild the archive.

    – Peter
    Jun 21 '15 at 8:24











  • Santosh and Peter, thank you so much for your responses. Santosh, not sure which version of tar is running on Mac OS x nor how to update it. Peter, thanks too. This isn't an option, since extracting the archive fails due to how large the error_log is.

    – KillerDesigner
    Jun 21 '15 at 15:09

















Which version of tar are you using? If its outdated then try to update to the latest version and check the man page if tar supports --delete as an option.

– Santosh A
Jun 21 '15 at 8:21





Which version of tar are you using? If its outdated then try to update to the latest version and check the man page if tar supports --delete as an option.

– Santosh A
Jun 21 '15 at 8:21




1




1





The --delete option is specific to some tar programs (notably the default available under linux). From memory, the default tar under macos does not support that. You'll need to read the man/help file, or obtain a program that supports such functionality. All else failing, unzip the .tar.gz file, extract everything from the archive, delete the unwanted file, and then rebuild the archive.

– Peter
Jun 21 '15 at 8:24





The --delete option is specific to some tar programs (notably the default available under linux). From memory, the default tar under macos does not support that. You'll need to read the man/help file, or obtain a program that supports such functionality. All else failing, unzip the .tar.gz file, extract everything from the archive, delete the unwanted file, and then rebuild the archive.

– Peter
Jun 21 '15 at 8:24













Santosh and Peter, thank you so much for your responses. Santosh, not sure which version of tar is running on Mac OS x nor how to update it. Peter, thanks too. This isn't an option, since extracting the archive fails due to how large the error_log is.

– KillerDesigner
Jun 21 '15 at 15:09





Santosh and Peter, thank you so much for your responses. Santosh, not sure which version of tar is running on Mac OS x nor how to update it. Peter, thanks too. This isn't an option, since extracting the archive fails due to how large the error_log is.

– KillerDesigner
Jun 21 '15 at 15:09












2 Answers
2






active

oldest

votes


















14














As mentioned in the comments it's not possible to remove the file using tar, but you can exclude the file when extracting:



tar -zxvf file.tar.gz --exclude "file_to_exclude"





share|improve this answer


























  • Worked like a charm. Thank you.

    – KillerDesigner
    Jun 21 '15 at 15:10



















-2














Dear you can delete the archive file through the same format as we remove the directory from below command through



command:- rm -rf archive file name
r:- recursively






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    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: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    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%2fstackoverflow.com%2fquestions%2f30962501%2fhow-do-i-delete-a-single-file-from-a-tar-gz-archive%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    14














    As mentioned in the comments it's not possible to remove the file using tar, but you can exclude the file when extracting:



    tar -zxvf file.tar.gz --exclude "file_to_exclude"





    share|improve this answer


























    • Worked like a charm. Thank you.

      – KillerDesigner
      Jun 21 '15 at 15:10
















    14














    As mentioned in the comments it's not possible to remove the file using tar, but you can exclude the file when extracting:



    tar -zxvf file.tar.gz --exclude "file_to_exclude"





    share|improve this answer


























    • Worked like a charm. Thank you.

      – KillerDesigner
      Jun 21 '15 at 15:10














    14












    14








    14







    As mentioned in the comments it's not possible to remove the file using tar, but you can exclude the file when extracting:



    tar -zxvf file.tar.gz --exclude "file_to_exclude"





    share|improve this answer















    As mentioned in the comments it's not possible to remove the file using tar, but you can exclude the file when extracting:



    tar -zxvf file.tar.gz --exclude "file_to_exclude"






    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Jun 21 '15 at 8:33

























    answered Jun 21 '15 at 8:27









    msfostermsfoster

    1,73311112




    1,73311112













    • Worked like a charm. Thank you.

      – KillerDesigner
      Jun 21 '15 at 15:10



















    • Worked like a charm. Thank you.

      – KillerDesigner
      Jun 21 '15 at 15:10

















    Worked like a charm. Thank you.

    – KillerDesigner
    Jun 21 '15 at 15:10





    Worked like a charm. Thank you.

    – KillerDesigner
    Jun 21 '15 at 15:10













    -2














    Dear you can delete the archive file through the same format as we remove the directory from below command through



    command:- rm -rf archive file name
    r:- recursively






    share|improve this answer




























      -2














      Dear you can delete the archive file through the same format as we remove the directory from below command through



      command:- rm -rf archive file name
      r:- recursively






      share|improve this answer


























        -2












        -2








        -2







        Dear you can delete the archive file through the same format as we remove the directory from below command through



        command:- rm -rf archive file name
        r:- recursively






        share|improve this answer













        Dear you can delete the archive file through the same format as we remove the directory from below command through



        command:- rm -rf archive file name
        r:- recursively







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 16 '18 at 1:10









        VinodVinod

        1




        1






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • 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%2fstackoverflow.com%2fquestions%2f30962501%2fhow-do-i-delete-a-single-file-from-a-tar-gz-archive%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

            The Sandy Post

            Danny Elfman

            Pages that link to "Head v. Amoskeag Manufacturing Co."