Create an archive with command “gzip”

archivegzip

I have to create an archive with the command gzip (not tar – it's necessary) and the archive should contain files from another directory – for example, /etc.
I tried to use command

gzip myetc.gz /etc

But it didn't work.

Best Answer

Gzip works only with a single file, or a stream - data piped to gzip. So you first need to generate one file, like with tar, and then you could gzip that. The other option is to gzip all individual files, and then tar that into one file.

Both these solutions are stupid and should not be used. You should use tar with the built in compression option and do it all in one command.

Related Question