How to set compression level here?
nice -n 19 tar -czf $out $in
nice won't do anything to the level of compression. It will only affect the scheduling of the process by the kernel. All commands below may be prefixed with
nice to run them at a different "nice"-level, it will not influence the level of compression, only the time taken to perform the action (if the system is under heavy load).
If you're using GNU
tar then the compression program may be set with either the
-I or the
$ tar -I "gzip --best" -c -f archive.tar.gz dir
$ tar --use-compress-program="gzip --best" -c -f archive.tar.gz dir
Note that the
-z option should not be used if you set the compression program explicitly.
tar manual states that the program used must support an
-d option for decompression (if you use these options for decompressing a compressed archive), which
tar it's not possible to specify the level of compression in a similar way, as far as I have seen.
The other way to achieve this is obviously to create an un-compressed archive and then compress that in the way one wants:
$ tar -c -f archive.tar dir $ gzip --best archive.tar
$ tar -c dir | gzip --best -o archive.tar.gz
Yet another way is to set the
GZIP environment variable to the flags that you'd like to pass to
$ export GZIP='--best' $ tar -c -z -f archive.tar.gz dir
Except for the use of
--use-compress-program, the last few alternatives work with both GNU and BSD