Is there a quick and dirty way of estimating gzip-compressibility of a file without having to fully compress it with gzip?I could, in bash, dobc <<<scale=2;$(gzip -c file | wc -c)/$(wc -c <file)This gives me the compression factor without having to write the gz file to disk; this way I can avoid replacing a file on disk with its gz version if the resultant disk space savings do not justify the trouble. But with this approach the file is indeed fully put through gzip; it's just that the output is piped to wc rather than written to disk.Is there a way to get a rough compressibility estimate for a file without having gzip work on all its contents?
Estimate compressibility of file
compression;gzip
You could try compressing one every 10 blocks for instance to get an idea:perl -MIPC::Open2 -nE 'BEGIN{$/=\4096;open2(\*I,\*O,gzip|wc -c)}                       if ($. % 10 == 1) {print O $_; $l+=length}                       END{close O; $c = <I>; say $c/$l}'(here with 4K blocks).