How to gzip multiple files into one gz file?

You want to tar your files together and gzip the resulting tar file.

tar cvzf cvd.tar.gz cvd*.txt

To untar the gzip'd tar file you would do:

tar xvzf cvd.tar.gz -C /path/to/parent/dir

This would extract your files under the /path/to/parent/dir directory


if you have zip,

zip myzip.zip cvd*.txt

Don't need to tar them first.


You'll want to use tar, like so:

tar -czvf file.tar.gz cvd*.txt

tar puts the files together, while gzip then performs the compression.

Quoth the gzip manpage:

If you wish to create a single archive file with multiple members so that members can later be extracted independently, use an archiver such as tar or zip. GNU tar supports the -z option to invoke gzip transparently. gzip is designed as a complement to tar, not as a replacement