Compression ratios of .tbz file

Hi,

I have a question about finding the compression ratios of a zip (bzip2) file.I have written a procedure which upon certain criteria tar's and bzip2 certain directories and moves them to a near line storage.

Yesterday I happened to stumble upon it. The procedure has tared and bzipped 6 GB of data to 800MB. Is there any attribute in tar command which would yield a summary of the compression.Though I have gone through the man page of tar, I have not found anything affirmative.

Thanks in advance
Syed

In short: no.
tar doesn't compress anything, it's just an archiver, meaning it combines a list of files (including meta information like access times, permissions, ...) into one larger file. As a bonus it supports passing this file stream through a compression utility like gzip or bzip2. These 2 commands are completely equal, and the resulting files usually even have the same checksum:

# tar -cf - directory | bzip2 -c > archive.tbz
# tar -cjf archive.tbz directory

One way to get the ratio would be by getting the sizes of the original and the compressed file with du, and feeding it to bc:

orig=$( du -k directory )
comp=$( du -k archive.tbz )
ratio=$( echo "scale=5; $comp/$orig*100" | bc )

Ok, is there anyway of doing it while we actually create the tbz file via tar command,the command I,m using is as follows

tar cjfPpT /path/to/file.tbz  /path/to/inputlist

No. Instead of du you could try capture the output of the --totals option, but that's about it.