gzip 2 files into one file
I want to gzip two or more files into one file, I checked this and this but both have files like: n1.txt
, n2.txt
, ... but my filenames are completely different, like: file.mp4
, bar.txt
, foo.jpeg
and I want to gzip them all and put the output into one file. This didn't help too:
gzip -c file.mp4 > test.gz
gzip -c bar.txt >> test.gz
Do I have to tar them first?
And another question: In tar files, we can watch inner files without decompression using:
tar -tvf filename.tar
Is there anyway to do this with gzip or bzip2?
command-line tar gzip bzip2
add a comment |
I want to gzip two or more files into one file, I checked this and this but both have files like: n1.txt
, n2.txt
, ... but my filenames are completely different, like: file.mp4
, bar.txt
, foo.jpeg
and I want to gzip them all and put the output into one file. This didn't help too:
gzip -c file.mp4 > test.gz
gzip -c bar.txt >> test.gz
Do I have to tar them first?
And another question: In tar files, we can watch inner files without decompression using:
tar -tvf filename.tar
Is there anyway to do this with gzip or bzip2?
command-line tar gzip bzip2
add a comment |
I want to gzip two or more files into one file, I checked this and this but both have files like: n1.txt
, n2.txt
, ... but my filenames are completely different, like: file.mp4
, bar.txt
, foo.jpeg
and I want to gzip them all and put the output into one file. This didn't help too:
gzip -c file.mp4 > test.gz
gzip -c bar.txt >> test.gz
Do I have to tar them first?
And another question: In tar files, we can watch inner files without decompression using:
tar -tvf filename.tar
Is there anyway to do this with gzip or bzip2?
command-line tar gzip bzip2
I want to gzip two or more files into one file, I checked this and this but both have files like: n1.txt
, n2.txt
, ... but my filenames are completely different, like: file.mp4
, bar.txt
, foo.jpeg
and I want to gzip them all and put the output into one file. This didn't help too:
gzip -c file.mp4 > test.gz
gzip -c bar.txt >> test.gz
Do I have to tar them first?
And another question: In tar files, we can watch inner files without decompression using:
tar -tvf filename.tar
Is there anyway to do this with gzip or bzip2?
command-line tar gzip bzip2
command-line tar gzip bzip2
edited Dec 19 '18 at 7:39
dessert
22.4k56198
22.4k56198
asked Dec 19 '18 at 6:48
Mohammad KholghiMohammad Kholghi
577
577
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
Unlike ZIP, RAR or 7-Zip, for example, gzip
can only compress one file. As you’ve already noted, there is the tar
program which can serialize multiple files into one which makes them ready for gzip
. The traditional Unix philosophy prefers to use multiple simpler and more specialized tools than one monolithic and complicated. In this case, it results in using tar
and gzip
consecutively, resulting in a .tar.gz
(or .tgz
) file.
However, GNU tar
includes the -z
option which compresses the result of the traditional tar
using gzip
in just one command.
.tar.gz
files are mostly created using the -czvf
options:
c
reate a new archive- g
z
ip (alternatives:j
for bzip2,J
for xz)
v
erbose (list processed files; optional)- output
f
ile (the following argument specifies the output file)
In your example, you can use the command:
tar -czvf test.tar.gz file.mp4 bar.txt
Is there any way to watch inner files without decompression with gzip or bzip2?
Yes, your command also works for a .tar.gz
file:
tar -tvf test.tar.gz
Further reading
- GNU TAR Manual page
- 10 quick tar command examples to create/extract archives in Linux
What a great answer
– progo
Dec 19 '18 at 14:00
1
The combination of two tools has also allowed the replacement of the compression method with others more efficient for a specific need. Modern versions of tar knows many compressors and can transparently invoke them when needed.
– Thorbjørn Ravn Andersen
Dec 19 '18 at 14:54
2
Little known fact: It is possible to compress multiple files withgzip
. But it's not very useful since when decompressing such a file withgunzip
it will just append all the original files into a single file. If you typeecho Foo > a ; gzip a
you will have a file calleda.gz
which contains both the name and timestamp of the originala
file. If you then typeecho Bar > b ; gzip b ; cat a.gz b.gz >combined.gz
you will have acombined.gz
file which contains all the information needed to reconstructa
andb
with their original names, contents, and timestamps.
– kasperd
Dec 19 '18 at 15:54
add a comment |
gzip
is a compressor, not an archiver, but it works well with tar
tar -cvzf file.tar.gz path-to-files-or-directories-to-compress
See man tar
Compression options
-a, --auto-compress
Use archive suffix to determine the compression program.
-I, --use-compress-program=COMMAND
Filter data through COMMAND. It must accept the -d option, for
decompression. The argument can contain command line options.
-j, --bzip2
Filter the archive through bzip2(1).
-J, --xz
Filter the archive through xz(1).
--lzip Filter the archive through lzip(1).
--lzma Filter the archive through lzma(1).
--lzop Filter the archive through lzop(1).
--no-auto-compress
Do not use archive suffix to determine the compression program.
-z, --gzip, --gunzip, --ungzip
Filter the archive through gzip(1).
-Z, --compress, --uncompress
Filter the archive through compress(1).
And yes, you can watch compressed archives the same way.
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
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: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
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%2faskubuntu.com%2fquestions%2f1103018%2fgzip-2-files-into-one-file%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Unlike ZIP, RAR or 7-Zip, for example, gzip
can only compress one file. As you’ve already noted, there is the tar
program which can serialize multiple files into one which makes them ready for gzip
. The traditional Unix philosophy prefers to use multiple simpler and more specialized tools than one monolithic and complicated. In this case, it results in using tar
and gzip
consecutively, resulting in a .tar.gz
(or .tgz
) file.
However, GNU tar
includes the -z
option which compresses the result of the traditional tar
using gzip
in just one command.
.tar.gz
files are mostly created using the -czvf
options:
c
reate a new archive- g
z
ip (alternatives:j
for bzip2,J
for xz)
v
erbose (list processed files; optional)- output
f
ile (the following argument specifies the output file)
In your example, you can use the command:
tar -czvf test.tar.gz file.mp4 bar.txt
Is there any way to watch inner files without decompression with gzip or bzip2?
Yes, your command also works for a .tar.gz
file:
tar -tvf test.tar.gz
Further reading
- GNU TAR Manual page
- 10 quick tar command examples to create/extract archives in Linux
What a great answer
– progo
Dec 19 '18 at 14:00
1
The combination of two tools has also allowed the replacement of the compression method with others more efficient for a specific need. Modern versions of tar knows many compressors and can transparently invoke them when needed.
– Thorbjørn Ravn Andersen
Dec 19 '18 at 14:54
2
Little known fact: It is possible to compress multiple files withgzip
. But it's not very useful since when decompressing such a file withgunzip
it will just append all the original files into a single file. If you typeecho Foo > a ; gzip a
you will have a file calleda.gz
which contains both the name and timestamp of the originala
file. If you then typeecho Bar > b ; gzip b ; cat a.gz b.gz >combined.gz
you will have acombined.gz
file which contains all the information needed to reconstructa
andb
with their original names, contents, and timestamps.
– kasperd
Dec 19 '18 at 15:54
add a comment |
Unlike ZIP, RAR or 7-Zip, for example, gzip
can only compress one file. As you’ve already noted, there is the tar
program which can serialize multiple files into one which makes them ready for gzip
. The traditional Unix philosophy prefers to use multiple simpler and more specialized tools than one monolithic and complicated. In this case, it results in using tar
and gzip
consecutively, resulting in a .tar.gz
(or .tgz
) file.
However, GNU tar
includes the -z
option which compresses the result of the traditional tar
using gzip
in just one command.
.tar.gz
files are mostly created using the -czvf
options:
c
reate a new archive- g
z
ip (alternatives:j
for bzip2,J
for xz)
v
erbose (list processed files; optional)- output
f
ile (the following argument specifies the output file)
In your example, you can use the command:
tar -czvf test.tar.gz file.mp4 bar.txt
Is there any way to watch inner files without decompression with gzip or bzip2?
Yes, your command also works for a .tar.gz
file:
tar -tvf test.tar.gz
Further reading
- GNU TAR Manual page
- 10 quick tar command examples to create/extract archives in Linux
What a great answer
– progo
Dec 19 '18 at 14:00
1
The combination of two tools has also allowed the replacement of the compression method with others more efficient for a specific need. Modern versions of tar knows many compressors and can transparently invoke them when needed.
– Thorbjørn Ravn Andersen
Dec 19 '18 at 14:54
2
Little known fact: It is possible to compress multiple files withgzip
. But it's not very useful since when decompressing such a file withgunzip
it will just append all the original files into a single file. If you typeecho Foo > a ; gzip a
you will have a file calleda.gz
which contains both the name and timestamp of the originala
file. If you then typeecho Bar > b ; gzip b ; cat a.gz b.gz >combined.gz
you will have acombined.gz
file which contains all the information needed to reconstructa
andb
with their original names, contents, and timestamps.
– kasperd
Dec 19 '18 at 15:54
add a comment |
Unlike ZIP, RAR or 7-Zip, for example, gzip
can only compress one file. As you’ve already noted, there is the tar
program which can serialize multiple files into one which makes them ready for gzip
. The traditional Unix philosophy prefers to use multiple simpler and more specialized tools than one monolithic and complicated. In this case, it results in using tar
and gzip
consecutively, resulting in a .tar.gz
(or .tgz
) file.
However, GNU tar
includes the -z
option which compresses the result of the traditional tar
using gzip
in just one command.
.tar.gz
files are mostly created using the -czvf
options:
c
reate a new archive- g
z
ip (alternatives:j
for bzip2,J
for xz)
v
erbose (list processed files; optional)- output
f
ile (the following argument specifies the output file)
In your example, you can use the command:
tar -czvf test.tar.gz file.mp4 bar.txt
Is there any way to watch inner files without decompression with gzip or bzip2?
Yes, your command also works for a .tar.gz
file:
tar -tvf test.tar.gz
Further reading
- GNU TAR Manual page
- 10 quick tar command examples to create/extract archives in Linux
Unlike ZIP, RAR or 7-Zip, for example, gzip
can only compress one file. As you’ve already noted, there is the tar
program which can serialize multiple files into one which makes them ready for gzip
. The traditional Unix philosophy prefers to use multiple simpler and more specialized tools than one monolithic and complicated. In this case, it results in using tar
and gzip
consecutively, resulting in a .tar.gz
(or .tgz
) file.
However, GNU tar
includes the -z
option which compresses the result of the traditional tar
using gzip
in just one command.
.tar.gz
files are mostly created using the -czvf
options:
c
reate a new archive- g
z
ip (alternatives:j
for bzip2,J
for xz)
v
erbose (list processed files; optional)- output
f
ile (the following argument specifies the output file)
In your example, you can use the command:
tar -czvf test.tar.gz file.mp4 bar.txt
Is there any way to watch inner files without decompression with gzip or bzip2?
Yes, your command also works for a .tar.gz
file:
tar -tvf test.tar.gz
Further reading
- GNU TAR Manual page
- 10 quick tar command examples to create/extract archives in Linux
edited Dec 19 '18 at 14:01
progo
1236
1236
answered Dec 19 '18 at 8:54
MelebiusMelebius
4,57751839
4,57751839
What a great answer
– progo
Dec 19 '18 at 14:00
1
The combination of two tools has also allowed the replacement of the compression method with others more efficient for a specific need. Modern versions of tar knows many compressors and can transparently invoke them when needed.
– Thorbjørn Ravn Andersen
Dec 19 '18 at 14:54
2
Little known fact: It is possible to compress multiple files withgzip
. But it's not very useful since when decompressing such a file withgunzip
it will just append all the original files into a single file. If you typeecho Foo > a ; gzip a
you will have a file calleda.gz
which contains both the name and timestamp of the originala
file. If you then typeecho Bar > b ; gzip b ; cat a.gz b.gz >combined.gz
you will have acombined.gz
file which contains all the information needed to reconstructa
andb
with their original names, contents, and timestamps.
– kasperd
Dec 19 '18 at 15:54
add a comment |
What a great answer
– progo
Dec 19 '18 at 14:00
1
The combination of two tools has also allowed the replacement of the compression method with others more efficient for a specific need. Modern versions of tar knows many compressors and can transparently invoke them when needed.
– Thorbjørn Ravn Andersen
Dec 19 '18 at 14:54
2
Little known fact: It is possible to compress multiple files withgzip
. But it's not very useful since when decompressing such a file withgunzip
it will just append all the original files into a single file. If you typeecho Foo > a ; gzip a
you will have a file calleda.gz
which contains both the name and timestamp of the originala
file. If you then typeecho Bar > b ; gzip b ; cat a.gz b.gz >combined.gz
you will have acombined.gz
file which contains all the information needed to reconstructa
andb
with their original names, contents, and timestamps.
– kasperd
Dec 19 '18 at 15:54
What a great answer
– progo
Dec 19 '18 at 14:00
What a great answer
– progo
Dec 19 '18 at 14:00
1
1
The combination of two tools has also allowed the replacement of the compression method with others more efficient for a specific need. Modern versions of tar knows many compressors and can transparently invoke them when needed.
– Thorbjørn Ravn Andersen
Dec 19 '18 at 14:54
The combination of two tools has also allowed the replacement of the compression method with others more efficient for a specific need. Modern versions of tar knows many compressors and can transparently invoke them when needed.
– Thorbjørn Ravn Andersen
Dec 19 '18 at 14:54
2
2
Little known fact: It is possible to compress multiple files with
gzip
. But it's not very useful since when decompressing such a file with gunzip
it will just append all the original files into a single file. If you type echo Foo > a ; gzip a
you will have a file called a.gz
which contains both the name and timestamp of the original a
file. If you then type echo Bar > b ; gzip b ; cat a.gz b.gz >combined.gz
you will have a combined.gz
file which contains all the information needed to reconstruct a
and b
with their original names, contents, and timestamps.– kasperd
Dec 19 '18 at 15:54
Little known fact: It is possible to compress multiple files with
gzip
. But it's not very useful since when decompressing such a file with gunzip
it will just append all the original files into a single file. If you type echo Foo > a ; gzip a
you will have a file called a.gz
which contains both the name and timestamp of the original a
file. If you then type echo Bar > b ; gzip b ; cat a.gz b.gz >combined.gz
you will have a combined.gz
file which contains all the information needed to reconstruct a
and b
with their original names, contents, and timestamps.– kasperd
Dec 19 '18 at 15:54
add a comment |
gzip
is a compressor, not an archiver, but it works well with tar
tar -cvzf file.tar.gz path-to-files-or-directories-to-compress
See man tar
Compression options
-a, --auto-compress
Use archive suffix to determine the compression program.
-I, --use-compress-program=COMMAND
Filter data through COMMAND. It must accept the -d option, for
decompression. The argument can contain command line options.
-j, --bzip2
Filter the archive through bzip2(1).
-J, --xz
Filter the archive through xz(1).
--lzip Filter the archive through lzip(1).
--lzma Filter the archive through lzma(1).
--lzop Filter the archive through lzop(1).
--no-auto-compress
Do not use archive suffix to determine the compression program.
-z, --gzip, --gunzip, --ungzip
Filter the archive through gzip(1).
-Z, --compress, --uncompress
Filter the archive through compress(1).
And yes, you can watch compressed archives the same way.
add a comment |
gzip
is a compressor, not an archiver, but it works well with tar
tar -cvzf file.tar.gz path-to-files-or-directories-to-compress
See man tar
Compression options
-a, --auto-compress
Use archive suffix to determine the compression program.
-I, --use-compress-program=COMMAND
Filter data through COMMAND. It must accept the -d option, for
decompression. The argument can contain command line options.
-j, --bzip2
Filter the archive through bzip2(1).
-J, --xz
Filter the archive through xz(1).
--lzip Filter the archive through lzip(1).
--lzma Filter the archive through lzma(1).
--lzop Filter the archive through lzop(1).
--no-auto-compress
Do not use archive suffix to determine the compression program.
-z, --gzip, --gunzip, --ungzip
Filter the archive through gzip(1).
-Z, --compress, --uncompress
Filter the archive through compress(1).
And yes, you can watch compressed archives the same way.
add a comment |
gzip
is a compressor, not an archiver, but it works well with tar
tar -cvzf file.tar.gz path-to-files-or-directories-to-compress
See man tar
Compression options
-a, --auto-compress
Use archive suffix to determine the compression program.
-I, --use-compress-program=COMMAND
Filter data through COMMAND. It must accept the -d option, for
decompression. The argument can contain command line options.
-j, --bzip2
Filter the archive through bzip2(1).
-J, --xz
Filter the archive through xz(1).
--lzip Filter the archive through lzip(1).
--lzma Filter the archive through lzma(1).
--lzop Filter the archive through lzop(1).
--no-auto-compress
Do not use archive suffix to determine the compression program.
-z, --gzip, --gunzip, --ungzip
Filter the archive through gzip(1).
-Z, --compress, --uncompress
Filter the archive through compress(1).
And yes, you can watch compressed archives the same way.
gzip
is a compressor, not an archiver, but it works well with tar
tar -cvzf file.tar.gz path-to-files-or-directories-to-compress
See man tar
Compression options
-a, --auto-compress
Use archive suffix to determine the compression program.
-I, --use-compress-program=COMMAND
Filter data through COMMAND. It must accept the -d option, for
decompression. The argument can contain command line options.
-j, --bzip2
Filter the archive through bzip2(1).
-J, --xz
Filter the archive through xz(1).
--lzip Filter the archive through lzip(1).
--lzma Filter the archive through lzma(1).
--lzop Filter the archive through lzop(1).
--no-auto-compress
Do not use archive suffix to determine the compression program.
-z, --gzip, --gunzip, --ungzip
Filter the archive through gzip(1).
-Z, --compress, --uncompress
Filter the archive through compress(1).
And yes, you can watch compressed archives the same way.
answered Dec 19 '18 at 7:02
sudodussudodus
23.3k32874
23.3k32874
add a comment |
add a comment |
Thanks for contributing an answer to Ask Ubuntu!
- 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%2faskubuntu.com%2fquestions%2f1103018%2fgzip-2-files-into-one-file%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