tar: compress text stdin and stdout [duplicate]

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











up vote
1
down vote

favorite













This question already has an answer here:



  • Is it possible to make a .tar.gz file directly from stdin? Or, I need to tar together already gzipped files

    4 answers



Using tar, is it possible to compress stdin text and have the compressed data appear in stdout? Example:



$ echo "test" | tar c - 
<compressed blob here>


I'm using macOS Mojave.










share|improve this question













marked as duplicate by Filipe Brandenburger, Kusalananda linux
Users with the  linux badge can single-handedly close linux questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Nov 22 at 18:23


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


















    up vote
    1
    down vote

    favorite













    This question already has an answer here:



    • Is it possible to make a .tar.gz file directly from stdin? Or, I need to tar together already gzipped files

      4 answers



    Using tar, is it possible to compress stdin text and have the compressed data appear in stdout? Example:



    $ echo "test" | tar c - 
    <compressed blob here>


    I'm using macOS Mojave.










    share|improve this question













    marked as duplicate by Filipe Brandenburger, Kusalananda linux
    Users with the  linux badge can single-handedly close linux questions as duplicates and reopen them as needed.

    StackExchange.ready(function()
    if (StackExchange.options.isMobile) return;

    $('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
    var $hover = $(this).addClass('hover-bound'),
    $msg = $hover.siblings('.dupe-hammer-message');

    $hover.hover(
    function()
    $hover.showInfoMessage('',
    messageElement: $msg.clone().show(),
    transient: false,
    position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
    dismissable: false,
    relativeToBody: true
    );
    ,
    function()
    StackExchange.helpers.removeMessages();

    );
    );
    );
    Nov 22 at 18:23


    This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
















      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite












      This question already has an answer here:



      • Is it possible to make a .tar.gz file directly from stdin? Or, I need to tar together already gzipped files

        4 answers



      Using tar, is it possible to compress stdin text and have the compressed data appear in stdout? Example:



      $ echo "test" | tar c - 
      <compressed blob here>


      I'm using macOS Mojave.










      share|improve this question














      This question already has an answer here:



      • Is it possible to make a .tar.gz file directly from stdin? Or, I need to tar together already gzipped files

        4 answers



      Using tar, is it possible to compress stdin text and have the compressed data appear in stdout? Example:



      $ echo "test" | tar c - 
      <compressed blob here>


      I'm using macOS Mojave.





      This question already has an answer here:



      • Is it possible to make a .tar.gz file directly from stdin? Or, I need to tar together already gzipped files

        4 answers







      linux terminal osx tar compression






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 22 at 18:09









      user322355

      82




      82




      marked as duplicate by Filipe Brandenburger, Kusalananda linux
      Users with the  linux badge can single-handedly close linux questions as duplicates and reopen them as needed.

      StackExchange.ready(function()
      if (StackExchange.options.isMobile) return;

      $('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
      var $hover = $(this).addClass('hover-bound'),
      $msg = $hover.siblings('.dupe-hammer-message');

      $hover.hover(
      function()
      $hover.showInfoMessage('',
      messageElement: $msg.clone().show(),
      transient: false,
      position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
      dismissable: false,
      relativeToBody: true
      );
      ,
      function()
      StackExchange.helpers.removeMessages();

      );
      );
      );
      Nov 22 at 18:23


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






      marked as duplicate by Filipe Brandenburger, Kusalananda linux
      Users with the  linux badge can single-handedly close linux questions as duplicates and reopen them as needed.

      StackExchange.ready(function()
      if (StackExchange.options.isMobile) return;

      $('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
      var $hover = $(this).addClass('hover-bound'),
      $msg = $hover.siblings('.dupe-hammer-message');

      $hover.hover(
      function()
      $hover.showInfoMessage('',
      messageElement: $msg.clone().show(),
      transient: false,
      position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
      dismissable: false,
      relativeToBody: true
      );
      ,
      function()
      StackExchange.helpers.removeMessages();

      );
      );
      );
      Nov 22 at 18:23


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          1
          down vote



          accepted










          In short, no it's not possible to do that without storing the whole contents of stdin into a file or temporary file (e.g. in memory.)



          This is a limitation of the tar file format itself, since before storing the file contents, tar stores a descriptor for the file, including file name, etc. and also the file size. So tar needs to know what is the size of the file before storing it. When reading from stdin, tar can't know the size of the contents, unless it reads all of them, in which case it'll need to store them somewhere, in order to store those contents in the tarball itself.



          See also "Is it possible to make a .tar.gz file directly from stdin? Or, I need to tar together already gzipped files." One of the answers lists a way to store the contents of the file first, then seek back and update the file descriptor to write the actual size of the contents. But that requires the ability to seek on the output file, which is typically not the case if you're writing to stdout...



          In short, you need to write your input to a temporary file, in order to add it to a tarball.






          share|improve this answer



























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            1
            down vote



            accepted










            In short, no it's not possible to do that without storing the whole contents of stdin into a file or temporary file (e.g. in memory.)



            This is a limitation of the tar file format itself, since before storing the file contents, tar stores a descriptor for the file, including file name, etc. and also the file size. So tar needs to know what is the size of the file before storing it. When reading from stdin, tar can't know the size of the contents, unless it reads all of them, in which case it'll need to store them somewhere, in order to store those contents in the tarball itself.



            See also "Is it possible to make a .tar.gz file directly from stdin? Or, I need to tar together already gzipped files." One of the answers lists a way to store the contents of the file first, then seek back and update the file descriptor to write the actual size of the contents. But that requires the ability to seek on the output file, which is typically not the case if you're writing to stdout...



            In short, you need to write your input to a temporary file, in order to add it to a tarball.






            share|improve this answer
























              up vote
              1
              down vote



              accepted










              In short, no it's not possible to do that without storing the whole contents of stdin into a file or temporary file (e.g. in memory.)



              This is a limitation of the tar file format itself, since before storing the file contents, tar stores a descriptor for the file, including file name, etc. and also the file size. So tar needs to know what is the size of the file before storing it. When reading from stdin, tar can't know the size of the contents, unless it reads all of them, in which case it'll need to store them somewhere, in order to store those contents in the tarball itself.



              See also "Is it possible to make a .tar.gz file directly from stdin? Or, I need to tar together already gzipped files." One of the answers lists a way to store the contents of the file first, then seek back and update the file descriptor to write the actual size of the contents. But that requires the ability to seek on the output file, which is typically not the case if you're writing to stdout...



              In short, you need to write your input to a temporary file, in order to add it to a tarball.






              share|improve this answer






















                up vote
                1
                down vote



                accepted







                up vote
                1
                down vote



                accepted






                In short, no it's not possible to do that without storing the whole contents of stdin into a file or temporary file (e.g. in memory.)



                This is a limitation of the tar file format itself, since before storing the file contents, tar stores a descriptor for the file, including file name, etc. and also the file size. So tar needs to know what is the size of the file before storing it. When reading from stdin, tar can't know the size of the contents, unless it reads all of them, in which case it'll need to store them somewhere, in order to store those contents in the tarball itself.



                See also "Is it possible to make a .tar.gz file directly from stdin? Or, I need to tar together already gzipped files." One of the answers lists a way to store the contents of the file first, then seek back and update the file descriptor to write the actual size of the contents. But that requires the ability to seek on the output file, which is typically not the case if you're writing to stdout...



                In short, you need to write your input to a temporary file, in order to add it to a tarball.






                share|improve this answer












                In short, no it's not possible to do that without storing the whole contents of stdin into a file or temporary file (e.g. in memory.)



                This is a limitation of the tar file format itself, since before storing the file contents, tar stores a descriptor for the file, including file name, etc. and also the file size. So tar needs to know what is the size of the file before storing it. When reading from stdin, tar can't know the size of the contents, unless it reads all of them, in which case it'll need to store them somewhere, in order to store those contents in the tarball itself.



                See also "Is it possible to make a .tar.gz file directly from stdin? Or, I need to tar together already gzipped files." One of the answers lists a way to store the contents of the file first, then seek back and update the file descriptor to write the actual size of the contents. But that requires the ability to seek on the output file, which is typically not the case if you're writing to stdout...



                In short, you need to write your input to a temporary file, in order to add it to a tarball.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 22 at 18:30









                Filipe Brandenburger

                6,5901731




                6,5901731












                    Popular posts from this blog

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

                    Bahrain

                    Postfix configuration issue with fips on centos 7; mailgun relay