João Portela
João Portela

Reputation: 6456

Script to change the compression of gziped files

I was trying to change the compression of some gzip files from the default compression level (6) or any other compression level to the maximum compression level (9).

Does anyone know how?

Upvotes: 0

Views: 475

Answers (2)

João Portela
João Portela

Reputation: 6456

found the solution but does not detect the compression level:

for file in ${files_to_process[*]}
do
    (gunzip -c ${file} | gzip -9 > ${file}.moarcompression) && mv ${file}.moarcompression ${file}
done

Upvotes: 0

Marcelo Cantos
Marcelo Cantos

Reputation: 185852

I don't know how to detect files with a default compression level, but the easiest way to set a new compression level is to simply uncompress then recompress:

for f in *.gz; do gunzip $f; gzip -9 ${f%.gz}; done

Upvotes: 1

Related Questions