Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

With GNU GZIP environment variable deprecated, how to control ZLIB compression via tar?

Currently I have a script that sets compression using the GZIP environment variable.

With gzip 1.8 I get a warning:

warning: GZIP environment variable is deprecated; use an alias or script

How should tar be invoked so the compression level be set?

Current command:

GZIP=-9 tar -zcf ... files to compress ...

like image 228
ideasman42 Avatar asked Sep 12 '17 04:09

ideasman42


2 Answers

Some older versions of tar do support the -I option to specify a compression command, however the older versions of tar do not support additional arguments to the compressor command. So older versions break when using something like -I 'gzip -9'.

A more portable and reliable solution is to handle the compression yourself with a pipe as mentioned in the other answer.

like image 197
dinominant Avatar answered Sep 20 '22 08:09

dinominant


You can specify the compression program using: -I / --use-compress-program=COMMAND.

So the original command:

GZIP=-9 tar -zcf ... files to compress ...

Becomes:

tar -I 'gzip -9' -cf ... files to compress ...

From this answer.

like image 27
ideasman42 Avatar answered Sep 20 '22 08:09

ideasman42