How to download an archive and extract it without saving the archive to disk?
Clash Royale CLAN TAG#URR8PPP
I'd like to download, and extract an archive under a given directory. Here is how I've been doing it so far:
wget http://downloads.mysql.com/source/dbt2-0.37.50.3.tar.gz
tar zxf dbt2-0.37.50.3.tar.gz
mv dbt2-0.37.50.3 dbt2
I'd like instead to download and extract the archive on the fly, without having the tar.gz
written to the disk. I think this is possible by piping the output of wget
to tar
, and giving tar
a target, but in practice I don't know how to put the pieces together.
shell pipe tar wget
add a comment |
I'd like to download, and extract an archive under a given directory. Here is how I've been doing it so far:
wget http://downloads.mysql.com/source/dbt2-0.37.50.3.tar.gz
tar zxf dbt2-0.37.50.3.tar.gz
mv dbt2-0.37.50.3 dbt2
I'd like instead to download and extract the archive on the fly, without having the tar.gz
written to the disk. I think this is possible by piping the output of wget
to tar
, and giving tar
a target, but in practice I don't know how to put the pieces together.
shell pipe tar wget
add a comment |
I'd like to download, and extract an archive under a given directory. Here is how I've been doing it so far:
wget http://downloads.mysql.com/source/dbt2-0.37.50.3.tar.gz
tar zxf dbt2-0.37.50.3.tar.gz
mv dbt2-0.37.50.3 dbt2
I'd like instead to download and extract the archive on the fly, without having the tar.gz
written to the disk. I think this is possible by piping the output of wget
to tar
, and giving tar
a target, but in practice I don't know how to put the pieces together.
shell pipe tar wget
I'd like to download, and extract an archive under a given directory. Here is how I've been doing it so far:
wget http://downloads.mysql.com/source/dbt2-0.37.50.3.tar.gz
tar zxf dbt2-0.37.50.3.tar.gz
mv dbt2-0.37.50.3 dbt2
I'd like instead to download and extract the archive on the fly, without having the tar.gz
written to the disk. I think this is possible by piping the output of wget
to tar
, and giving tar
a target, but in practice I don't know how to put the pieces together.
shell pipe tar wget
shell pipe tar wget
edited Aug 1 '13 at 23:31
Gilles
540k12810941608
540k12810941608
asked Aug 1 '13 at 14:19
BenjaminBenjamin
1,30741935
1,30741935
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
You can do it by telling wget
to output its payload to stdout (with flag -O-
) and supress its own output (with flag -q
):
wget -qO- your_link_here | tar xvz -
To specify a target directory:
wget -qO- your_link_here | tar xvz - -C /target/directory
Update
If you happen to have GNU tar
wget -qO- your_link_here | tar --transform 's/^dbt2-0.37.50.3/dbt2/' -xvz
should allow you to do it all in one step.
-q
quiet
-O -
output to stdout
To specified path should be:wget -qO- your_link_here | tar xvz - -C /target/directory
– Marslo
Sep 12 '18 at 12:10
add a comment |
This oneliner does the trick:
tar xvzf -C /tmp/ < <(wget -q -O - http://foo.com/myfile.tar.gz)
short explanation:
the right side in the parenthesis is executed first (-q
tells wget to do it quietly, -O -
is used to write the output to stdout).
Then we create a named pipe using the process substitution operator from Bash <(
to create a named pipe.
This way we create a temporary file descriptor and then direct the contents of that descriptor to tar using the <
file redirection operator.
add a comment |
Another option is to use curl
which writes to stdout by default:
curl -s some_url | tar xvz -C /tmp
add a comment |
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/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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f85194%2fhow-to-download-an-archive-and-extract-it-without-saving-the-archive-to-disk%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can do it by telling wget
to output its payload to stdout (with flag -O-
) and supress its own output (with flag -q
):
wget -qO- your_link_here | tar xvz -
To specify a target directory:
wget -qO- your_link_here | tar xvz - -C /target/directory
Update
If you happen to have GNU tar
wget -qO- your_link_here | tar --transform 's/^dbt2-0.37.50.3/dbt2/' -xvz
should allow you to do it all in one step.
-q
quiet
-O -
output to stdout
To specified path should be:wget -qO- your_link_here | tar xvz - -C /target/directory
– Marslo
Sep 12 '18 at 12:10
add a comment |
You can do it by telling wget
to output its payload to stdout (with flag -O-
) and supress its own output (with flag -q
):
wget -qO- your_link_here | tar xvz -
To specify a target directory:
wget -qO- your_link_here | tar xvz - -C /target/directory
Update
If you happen to have GNU tar
wget -qO- your_link_here | tar --transform 's/^dbt2-0.37.50.3/dbt2/' -xvz
should allow you to do it all in one step.
-q
quiet
-O -
output to stdout
To specified path should be:wget -qO- your_link_here | tar xvz - -C /target/directory
– Marslo
Sep 12 '18 at 12:10
add a comment |
You can do it by telling wget
to output its payload to stdout (with flag -O-
) and supress its own output (with flag -q
):
wget -qO- your_link_here | tar xvz -
To specify a target directory:
wget -qO- your_link_here | tar xvz - -C /target/directory
Update
If you happen to have GNU tar
wget -qO- your_link_here | tar --transform 's/^dbt2-0.37.50.3/dbt2/' -xvz
should allow you to do it all in one step.
-q
quiet
-O -
output to stdout
You can do it by telling wget
to output its payload to stdout (with flag -O-
) and supress its own output (with flag -q
):
wget -qO- your_link_here | tar xvz -
To specify a target directory:
wget -qO- your_link_here | tar xvz - -C /target/directory
Update
If you happen to have GNU tar
wget -qO- your_link_here | tar --transform 's/^dbt2-0.37.50.3/dbt2/' -xvz
should allow you to do it all in one step.
-q
quiet
-O -
output to stdout
edited Feb 10 at 0:49
MrE
253310
253310
answered Aug 1 '13 at 14:23
Joseph R.Joseph R.
28.5k375116
28.5k375116
To specified path should be:wget -qO- your_link_here | tar xvz - -C /target/directory
– Marslo
Sep 12 '18 at 12:10
add a comment |
To specified path should be:wget -qO- your_link_here | tar xvz - -C /target/directory
– Marslo
Sep 12 '18 at 12:10
To specified path should be:
wget -qO- your_link_here | tar xvz - -C /target/directory
– Marslo
Sep 12 '18 at 12:10
To specified path should be:
wget -qO- your_link_here | tar xvz - -C /target/directory
– Marslo
Sep 12 '18 at 12:10
add a comment |
This oneliner does the trick:
tar xvzf -C /tmp/ < <(wget -q -O - http://foo.com/myfile.tar.gz)
short explanation:
the right side in the parenthesis is executed first (-q
tells wget to do it quietly, -O -
is used to write the output to stdout).
Then we create a named pipe using the process substitution operator from Bash <(
to create a named pipe.
This way we create a temporary file descriptor and then direct the contents of that descriptor to tar using the <
file redirection operator.
add a comment |
This oneliner does the trick:
tar xvzf -C /tmp/ < <(wget -q -O - http://foo.com/myfile.tar.gz)
short explanation:
the right side in the parenthesis is executed first (-q
tells wget to do it quietly, -O -
is used to write the output to stdout).
Then we create a named pipe using the process substitution operator from Bash <(
to create a named pipe.
This way we create a temporary file descriptor and then direct the contents of that descriptor to tar using the <
file redirection operator.
add a comment |
This oneliner does the trick:
tar xvzf -C /tmp/ < <(wget -q -O - http://foo.com/myfile.tar.gz)
short explanation:
the right side in the parenthesis is executed first (-q
tells wget to do it quietly, -O -
is used to write the output to stdout).
Then we create a named pipe using the process substitution operator from Bash <(
to create a named pipe.
This way we create a temporary file descriptor and then direct the contents of that descriptor to tar using the <
file redirection operator.
This oneliner does the trick:
tar xvzf -C /tmp/ < <(wget -q -O - http://foo.com/myfile.tar.gz)
short explanation:
the right side in the parenthesis is executed first (-q
tells wget to do it quietly, -O -
is used to write the output to stdout).
Then we create a named pipe using the process substitution operator from Bash <(
to create a named pipe.
This way we create a temporary file descriptor and then direct the contents of that descriptor to tar using the <
file redirection operator.
edited Aug 25 '14 at 19:57
Daniel Serodio
7181714
7181714
answered Aug 1 '13 at 14:49
ItsMeItsMe
1963
1963
add a comment |
add a comment |
Another option is to use curl
which writes to stdout by default:
curl -s some_url | tar xvz -C /tmp
add a comment |
Another option is to use curl
which writes to stdout by default:
curl -s some_url | tar xvz -C /tmp
add a comment |
Another option is to use curl
which writes to stdout by default:
curl -s some_url | tar xvz -C /tmp
Another option is to use curl
which writes to stdout by default:
curl -s some_url | tar xvz -C /tmp
answered Mar 12 '18 at 21:46
Zlemini Zlemini
20326
20326
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f85194%2fhow-to-download-an-archive-and-extract-it-without-saving-the-archive-to-disk%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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