tar: compress text stdin and stdout [duplicate]
Clash 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.
linux terminal osx tar compression
marked as duplicate by Filipe Brandenburger, Kusalananda
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.
add a comment |
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.
linux terminal osx tar compression
marked as duplicate by Filipe Brandenburger, Kusalananda
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.
add a comment |
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.
linux terminal osx tar compression
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
linux terminal osx tar compression
asked Nov 22 at 18:09
user322355
82
82
marked as duplicate by Filipe Brandenburger, Kusalananda
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
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.
add a comment |
add a comment |
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.
add a comment |
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.
add a comment |
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.
add a comment |
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.
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.
answered Nov 22 at 18:30
Filipe Brandenburger
6,5901731
6,5901731
add a comment |
add a comment |