Make tar archive in parent directory

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











up vote
-1
down vote

favorite












I am currently trying to bundle certain files in my current directory into a tar archive, and then make it so the archive is in the parent of my current directory. I'm wondering if anyone could explain to me how to do this. I understand how to bundle the files I need, but I am confused as to how I can make it so the archive is in the parent.



Currently I am using the command:



$ tar -tvf something.tar $( find -name "*.txt")


as I need to bundle files with the .txt extension.










share|improve this question



















  • 1




    By the way, the question and answer assume GNU findutils is used, because it omits the (POSIX-required) parameter before -name.
    – Thomas Dickey
    Sep 11 at 1:03










  • @ThomasDickey I'm going to assume that the command worked as the answer was accepted (it also worked in the environment where I tested) but I went ahead and added the find command with the parameters before -name at the end of my answer as you've made a good point.
    – Nasir Riley
    Sep 11 at 12:05















up vote
-1
down vote

favorite












I am currently trying to bundle certain files in my current directory into a tar archive, and then make it so the archive is in the parent of my current directory. I'm wondering if anyone could explain to me how to do this. I understand how to bundle the files I need, but I am confused as to how I can make it so the archive is in the parent.



Currently I am using the command:



$ tar -tvf something.tar $( find -name "*.txt")


as I need to bundle files with the .txt extension.










share|improve this question



















  • 1




    By the way, the question and answer assume GNU findutils is used, because it omits the (POSIX-required) parameter before -name.
    – Thomas Dickey
    Sep 11 at 1:03










  • @ThomasDickey I'm going to assume that the command worked as the answer was accepted (it also worked in the environment where I tested) but I went ahead and added the find command with the parameters before -name at the end of my answer as you've made a good point.
    – Nasir Riley
    Sep 11 at 12:05













up vote
-1
down vote

favorite









up vote
-1
down vote

favorite











I am currently trying to bundle certain files in my current directory into a tar archive, and then make it so the archive is in the parent of my current directory. I'm wondering if anyone could explain to me how to do this. I understand how to bundle the files I need, but I am confused as to how I can make it so the archive is in the parent.



Currently I am using the command:



$ tar -tvf something.tar $( find -name "*.txt")


as I need to bundle files with the .txt extension.










share|improve this question















I am currently trying to bundle certain files in my current directory into a tar archive, and then make it so the archive is in the parent of my current directory. I'm wondering if anyone could explain to me how to do this. I understand how to bundle the files I need, but I am confused as to how I can make it so the archive is in the parent.



Currently I am using the command:



$ tar -tvf something.tar $( find -name "*.txt")


as I need to bundle files with the .txt extension.







shell tar






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Sep 11 at 0:51









slm♦

239k65494665




239k65494665










asked Sep 11 at 0:14









Anthony Rulli

83




83







  • 1




    By the way, the question and answer assume GNU findutils is used, because it omits the (POSIX-required) parameter before -name.
    – Thomas Dickey
    Sep 11 at 1:03










  • @ThomasDickey I'm going to assume that the command worked as the answer was accepted (it also worked in the environment where I tested) but I went ahead and added the find command with the parameters before -name at the end of my answer as you've made a good point.
    – Nasir Riley
    Sep 11 at 12:05













  • 1




    By the way, the question and answer assume GNU findutils is used, because it omits the (POSIX-required) parameter before -name.
    – Thomas Dickey
    Sep 11 at 1:03










  • @ThomasDickey I'm going to assume that the command worked as the answer was accepted (it also worked in the environment where I tested) but I went ahead and added the find command with the parameters before -name at the end of my answer as you've made a good point.
    – Nasir Riley
    Sep 11 at 12:05








1




1




By the way, the question and answer assume GNU findutils is used, because it omits the (POSIX-required) parameter before -name.
– Thomas Dickey
Sep 11 at 1:03




By the way, the question and answer assume GNU findutils is used, because it omits the (POSIX-required) parameter before -name.
– Thomas Dickey
Sep 11 at 1:03












@ThomasDickey I'm going to assume that the command worked as the answer was accepted (it also worked in the environment where I tested) but I went ahead and added the find command with the parameters before -name at the end of my answer as you've made a good point.
– Nasir Riley
Sep 11 at 12:05





@ThomasDickey I'm going to assume that the command worked as the answer was accepted (it also worked in the environment where I tested) but I went ahead and added the find command with the parameters before -name at the end of my answer as you've made a good point.
– Nasir Riley
Sep 11 at 12:05











1 Answer
1






active

oldest

votes

















up vote
2
down vote



accepted










You can do it one of a few ways:



tar cvf ../something.tar $( find -name "*.txt")


That will make it so that the files are put into something.tar in the directory right above.



A more long-winded way is this:



tar cvf /path/to/something.tar $( find -name "*.txt")


That uses the direct path to where you want to put the .tar file.



If you want actual compression:



tar cvfz something.tar.gz $( find -name "*.txt")


The z will put it into a .gz archive.



Basically, you want to use cvf or cfvz as the c will compress the contents into an actual archive. Using t as in your tvf command is to send the contents of the archive to standard output without extracting it which won't work as you haven't creating the .tar archive yet.



You may also need to escape the * depending on your environment:



tar cvf ../something.tar $( find -name "*.txt")


Another update for anyone who may need this in the future:



For anyone else who wants to use this, if you don't have findutils installed, it will be necessary to include the path that you are searching before -name in the find command:



tar cvf ../something.tar $( find . -name "*.txt")

tar cvf ../something.tar $( find /path/to/directory -name "*.txt")


The first searches in the current directory and the second searches using the path to the directory.






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%2f468137%2fmake-tar-archive-in-parent-directory%23new-answer', 'question_page');

    );

    Post as a guest






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    2
    down vote



    accepted










    You can do it one of a few ways:



    tar cvf ../something.tar $( find -name "*.txt")


    That will make it so that the files are put into something.tar in the directory right above.



    A more long-winded way is this:



    tar cvf /path/to/something.tar $( find -name "*.txt")


    That uses the direct path to where you want to put the .tar file.



    If you want actual compression:



    tar cvfz something.tar.gz $( find -name "*.txt")


    The z will put it into a .gz archive.



    Basically, you want to use cvf or cfvz as the c will compress the contents into an actual archive. Using t as in your tvf command is to send the contents of the archive to standard output without extracting it which won't work as you haven't creating the .tar archive yet.



    You may also need to escape the * depending on your environment:



    tar cvf ../something.tar $( find -name "*.txt")


    Another update for anyone who may need this in the future:



    For anyone else who wants to use this, if you don't have findutils installed, it will be necessary to include the path that you are searching before -name in the find command:



    tar cvf ../something.tar $( find . -name "*.txt")

    tar cvf ../something.tar $( find /path/to/directory -name "*.txt")


    The first searches in the current directory and the second searches using the path to the directory.






    share|improve this answer


























      up vote
      2
      down vote



      accepted










      You can do it one of a few ways:



      tar cvf ../something.tar $( find -name "*.txt")


      That will make it so that the files are put into something.tar in the directory right above.



      A more long-winded way is this:



      tar cvf /path/to/something.tar $( find -name "*.txt")


      That uses the direct path to where you want to put the .tar file.



      If you want actual compression:



      tar cvfz something.tar.gz $( find -name "*.txt")


      The z will put it into a .gz archive.



      Basically, you want to use cvf or cfvz as the c will compress the contents into an actual archive. Using t as in your tvf command is to send the contents of the archive to standard output without extracting it which won't work as you haven't creating the .tar archive yet.



      You may also need to escape the * depending on your environment:



      tar cvf ../something.tar $( find -name "*.txt")


      Another update for anyone who may need this in the future:



      For anyone else who wants to use this, if you don't have findutils installed, it will be necessary to include the path that you are searching before -name in the find command:



      tar cvf ../something.tar $( find . -name "*.txt")

      tar cvf ../something.tar $( find /path/to/directory -name "*.txt")


      The first searches in the current directory and the second searches using the path to the directory.






      share|improve this answer
























        up vote
        2
        down vote



        accepted







        up vote
        2
        down vote



        accepted






        You can do it one of a few ways:



        tar cvf ../something.tar $( find -name "*.txt")


        That will make it so that the files are put into something.tar in the directory right above.



        A more long-winded way is this:



        tar cvf /path/to/something.tar $( find -name "*.txt")


        That uses the direct path to where you want to put the .tar file.



        If you want actual compression:



        tar cvfz something.tar.gz $( find -name "*.txt")


        The z will put it into a .gz archive.



        Basically, you want to use cvf or cfvz as the c will compress the contents into an actual archive. Using t as in your tvf command is to send the contents of the archive to standard output without extracting it which won't work as you haven't creating the .tar archive yet.



        You may also need to escape the * depending on your environment:



        tar cvf ../something.tar $( find -name "*.txt")


        Another update for anyone who may need this in the future:



        For anyone else who wants to use this, if you don't have findutils installed, it will be necessary to include the path that you are searching before -name in the find command:



        tar cvf ../something.tar $( find . -name "*.txt")

        tar cvf ../something.tar $( find /path/to/directory -name "*.txt")


        The first searches in the current directory and the second searches using the path to the directory.






        share|improve this answer














        You can do it one of a few ways:



        tar cvf ../something.tar $( find -name "*.txt")


        That will make it so that the files are put into something.tar in the directory right above.



        A more long-winded way is this:



        tar cvf /path/to/something.tar $( find -name "*.txt")


        That uses the direct path to where you want to put the .tar file.



        If you want actual compression:



        tar cvfz something.tar.gz $( find -name "*.txt")


        The z will put it into a .gz archive.



        Basically, you want to use cvf or cfvz as the c will compress the contents into an actual archive. Using t as in your tvf command is to send the contents of the archive to standard output without extracting it which won't work as you haven't creating the .tar archive yet.



        You may also need to escape the * depending on your environment:



        tar cvf ../something.tar $( find -name "*.txt")


        Another update for anyone who may need this in the future:



        For anyone else who wants to use this, if you don't have findutils installed, it will be necessary to include the path that you are searching before -name in the find command:



        tar cvf ../something.tar $( find . -name "*.txt")

        tar cvf ../something.tar $( find /path/to/directory -name "*.txt")


        The first searches in the current directory and the second searches using the path to the directory.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Sep 11 at 15:35

























        answered Sep 11 at 0:28









        Nasir Riley

        1,754139




        1,754139



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f468137%2fmake-tar-archive-in-parent-directory%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?