How do I gunzip to a different destination directory?
up vote
67
down vote
favorite
How do I gunzip to a destination directory other than the current one?
This did not work:
gunzip *.gz /putthemhere/
linux unix gunzip
add a comment |
up vote
67
down vote
favorite
How do I gunzip to a destination directory other than the current one?
This did not work:
gunzip *.gz /putthemhere/
linux unix gunzip
add a comment |
up vote
67
down vote
favorite
up vote
67
down vote
favorite
How do I gunzip to a destination directory other than the current one?
This did not work:
gunzip *.gz /putthemhere/
linux unix gunzip
How do I gunzip to a destination directory other than the current one?
This did not work:
gunzip *.gz /putthemhere/
linux unix gunzip
linux unix gunzip
edited Oct 29 '14 at 19:55
Der Hochstapler
67k48230283
67k48230283
asked May 9 '10 at 23:15
Scott Szretter
69831324
69831324
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
up vote
87
down vote
accepted
Ask gunzip
to output to standard output and redirect to a file in that directory:
gunzip -c file.gz > /THERE/file
zcat
is a shortcut for gunzip -c
.
If you want to gunzip multiple files iterate over all files:
for f in *.gz; do
STEM=$(basename "${f}" .gz)
gunzip -c "${f}" > /THERE/"${STEM}"
done
(here basename
is used to get the part of the filename without the extension)
2
Creates the file, but does not preserve file ownership, permissions etc. That may be good or bad depending on your precise situation.
– Chris Johnson
Nov 9 '14 at 17:12
add a comment |
up vote
1
down vote
You can try with > to redirect the result to the place you want.
add a comment |
up vote
1
down vote
If you need to extract a single file and write into a root-owned directory, then use sudo dd
:
zcat filename.conf.gz | sudo tee /etc/filename.conf >/dev/null
If the file is coming from a remote source (i.e., ssh, curl https, etc), you can do it like this:
ssh remoteserver cat filename.conf.gz | zcat | sudo tee /etc/filename.conf >/dev/null
(Note that these examples only work for a single file, unlike the example *.gz, which is all gzipped files in the directory.)
For writing with root privileges,sudo tee $filename >/dev/null
is a little more idiomatic than usingdd
.
– dcoles
Nov 17 at 21:17
add a comment |
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
87
down vote
accepted
Ask gunzip
to output to standard output and redirect to a file in that directory:
gunzip -c file.gz > /THERE/file
zcat
is a shortcut for gunzip -c
.
If you want to gunzip multiple files iterate over all files:
for f in *.gz; do
STEM=$(basename "${f}" .gz)
gunzip -c "${f}" > /THERE/"${STEM}"
done
(here basename
is used to get the part of the filename without the extension)
2
Creates the file, but does not preserve file ownership, permissions etc. That may be good or bad depending on your precise situation.
– Chris Johnson
Nov 9 '14 at 17:12
add a comment |
up vote
87
down vote
accepted
Ask gunzip
to output to standard output and redirect to a file in that directory:
gunzip -c file.gz > /THERE/file
zcat
is a shortcut for gunzip -c
.
If you want to gunzip multiple files iterate over all files:
for f in *.gz; do
STEM=$(basename "${f}" .gz)
gunzip -c "${f}" > /THERE/"${STEM}"
done
(here basename
is used to get the part of the filename without the extension)
2
Creates the file, but does not preserve file ownership, permissions etc. That may be good or bad depending on your precise situation.
– Chris Johnson
Nov 9 '14 at 17:12
add a comment |
up vote
87
down vote
accepted
up vote
87
down vote
accepted
Ask gunzip
to output to standard output and redirect to a file in that directory:
gunzip -c file.gz > /THERE/file
zcat
is a shortcut for gunzip -c
.
If you want to gunzip multiple files iterate over all files:
for f in *.gz; do
STEM=$(basename "${f}" .gz)
gunzip -c "${f}" > /THERE/"${STEM}"
done
(here basename
is used to get the part of the filename without the extension)
Ask gunzip
to output to standard output and redirect to a file in that directory:
gunzip -c file.gz > /THERE/file
zcat
is a shortcut for gunzip -c
.
If you want to gunzip multiple files iterate over all files:
for f in *.gz; do
STEM=$(basename "${f}" .gz)
gunzip -c "${f}" > /THERE/"${STEM}"
done
(here basename
is used to get the part of the filename without the extension)
edited Jul 25 '12 at 20:56
answered May 9 '10 at 23:23
Benjamin Bannier
12.7k23637
12.7k23637
2
Creates the file, but does not preserve file ownership, permissions etc. That may be good or bad depending on your precise situation.
– Chris Johnson
Nov 9 '14 at 17:12
add a comment |
2
Creates the file, but does not preserve file ownership, permissions etc. That may be good or bad depending on your precise situation.
– Chris Johnson
Nov 9 '14 at 17:12
2
2
Creates the file, but does not preserve file ownership, permissions etc. That may be good or bad depending on your precise situation.
– Chris Johnson
Nov 9 '14 at 17:12
Creates the file, but does not preserve file ownership, permissions etc. That may be good or bad depending on your precise situation.
– Chris Johnson
Nov 9 '14 at 17:12
add a comment |
up vote
1
down vote
You can try with > to redirect the result to the place you want.
add a comment |
up vote
1
down vote
You can try with > to redirect the result to the place you want.
add a comment |
up vote
1
down vote
up vote
1
down vote
You can try with > to redirect the result to the place you want.
You can try with > to redirect the result to the place you want.
answered May 9 '10 at 23:21
jangelfdez
20212
20212
add a comment |
add a comment |
up vote
1
down vote
If you need to extract a single file and write into a root-owned directory, then use sudo dd
:
zcat filename.conf.gz | sudo tee /etc/filename.conf >/dev/null
If the file is coming from a remote source (i.e., ssh, curl https, etc), you can do it like this:
ssh remoteserver cat filename.conf.gz | zcat | sudo tee /etc/filename.conf >/dev/null
(Note that these examples only work for a single file, unlike the example *.gz, which is all gzipped files in the directory.)
For writing with root privileges,sudo tee $filename >/dev/null
is a little more idiomatic than usingdd
.
– dcoles
Nov 17 at 21:17
add a comment |
up vote
1
down vote
If you need to extract a single file and write into a root-owned directory, then use sudo dd
:
zcat filename.conf.gz | sudo tee /etc/filename.conf >/dev/null
If the file is coming from a remote source (i.e., ssh, curl https, etc), you can do it like this:
ssh remoteserver cat filename.conf.gz | zcat | sudo tee /etc/filename.conf >/dev/null
(Note that these examples only work for a single file, unlike the example *.gz, which is all gzipped files in the directory.)
For writing with root privileges,sudo tee $filename >/dev/null
is a little more idiomatic than usingdd
.
– dcoles
Nov 17 at 21:17
add a comment |
up vote
1
down vote
up vote
1
down vote
If you need to extract a single file and write into a root-owned directory, then use sudo dd
:
zcat filename.conf.gz | sudo tee /etc/filename.conf >/dev/null
If the file is coming from a remote source (i.e., ssh, curl https, etc), you can do it like this:
ssh remoteserver cat filename.conf.gz | zcat | sudo tee /etc/filename.conf >/dev/null
(Note that these examples only work for a single file, unlike the example *.gz, which is all gzipped files in the directory.)
If you need to extract a single file and write into a root-owned directory, then use sudo dd
:
zcat filename.conf.gz | sudo tee /etc/filename.conf >/dev/null
If the file is coming from a remote source (i.e., ssh, curl https, etc), you can do it like this:
ssh remoteserver cat filename.conf.gz | zcat | sudo tee /etc/filename.conf >/dev/null
(Note that these examples only work for a single file, unlike the example *.gz, which is all gzipped files in the directory.)
edited Nov 21 at 17:04
answered Jan 9 '17 at 20:24
Jamieson Becker
23114
23114
For writing with root privileges,sudo tee $filename >/dev/null
is a little more idiomatic than usingdd
.
– dcoles
Nov 17 at 21:17
add a comment |
For writing with root privileges,sudo tee $filename >/dev/null
is a little more idiomatic than usingdd
.
– dcoles
Nov 17 at 21:17
For writing with root privileges,
sudo tee $filename >/dev/null
is a little more idiomatic than using dd
.– dcoles
Nov 17 at 21:17
For writing with root privileges,
sudo tee $filename >/dev/null
is a little more idiomatic than using dd
.– dcoles
Nov 17 at 21:17
add a comment |
Thanks for contributing an answer to Super User!
- 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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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%2fsuperuser.com%2fquestions%2f139419%2fhow-do-i-gunzip-to-a-different-destination-directory%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