Sunday 15 September 2013

linux - Is there a utility for estimating a file's size after compression? -



linux - Is there a utility for estimating a file's size after compression? -

i estimate final size of file, files, or directory of files after has been compressed. i'm looking programme or script can estimate/calculate this.

any ideas?

such tool must accessible on command line (for linux/mac). useful if work or of commonly-used lossless compression algorithms (gz, bzip2, zip, etc.). bonus points if listed compression ratios (or of equivalent use, resulting file size) variety of methods. expect such tool scan file prior producing output, want avoid actual compression, if possible.

if matters, i'd prefer general-purpose:

it should work kind of file(s), including easily-compressed ascii text files, binary data, , in between. (of course, depends wildly on compression algorithm/tool.) it should work variety of compression algorithms/tools

the next bash script want one kind of compression algorithm, doesn't count (i'd estimation):

class="lang-bash prettyprint-override">#!/bin/bash files_to_compress=`ls ./*txt` temp_file=mydata.tgz tar -zcvf $temp_file $files_to_compress du -h $temp_file | awk '{print $1}' rm -f $temp_file

i utilize larger files (larger gigabyte), why want estimate, , not actual compression.

you might compress pipe | wc (you utilize pipe(7)-s or fifo(7)-s, perhaps bash coprocesses) still need compress.

(unless tight on disk space, believe not worth pain)

notice not every file genuinely compressible.

linux compression decompression data-compression lossless-compression

No comments:

Post a Comment