Trying to create a .gz archive - my_gz.gz - and add multiple files to it:
$ gzip my_gz.gz file1.txt file12.txt
gzip: can't stat: my_gz.gz: No such file or directory
You cannot add multiple files using gzip
because it is only a compression program, not an archiver. To compress multiple files, you would want to use tar
with gzip
:
tar czf archive.tar.gz file1.txt file2.txt
The z
tells the archiver to automatically use gzip
for compression. You could also tell it to use different compression algorithm. See the tar(1)
manual page for more information on this.