Compression ratios of .tbz file

 
Thread Tools Search this Thread
Operating Systems Linux Red Hat Compression ratios of .tbz file
# 1  
Old 09-13-2011
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
# 2  
Old 09-13-2011
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:
Code:
# 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:
Code:
orig=$( du -k directory )
comp=$( du -k archive.tbz )
ratio=$( echo "scale=5; $comp/$orig*100" | bc )

# 3  
Old 09-13-2011
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

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

# 4  
Old 09-13-2011
No. Instead of du you could try capture the output of the --totals option, but that's about it.
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Programming

Calculate ratios for each pair in a given file

Hello, My input file looks like this #CHROM POS ID REF ALT QUAL FILTER INFO FORMAT Individual1 Individual2 Individual3 Individual4 Individual5 Individual6 22 10000 ID1 A ... (0 Replies)
Discussion started by: nans
0 Replies

2. UNIX for Advanced & Expert Users

Compression with openssl

Hi , 1-I need to know please if it's possible to compress using openssl? Here is the version used: openssl version -a OpenSSL 0.9.7d 17 Mar 2004 (+ security fixes for: CVE-2005-2969 CVE-2006-2937 CVE-2006-2940 CVE2006-3738 CVE-2006-4339 CVE-2006-4343 CVE-2007-5135 CVE-2008-5077... (3 Replies)
Discussion started by: Eman_in_forum
3 Replies

3. Linux

Best Compression technique ?

Hi all, I am working on a sample backup code, where i read the files per 7200 bytes and send it to server. Before sending to server, i compress each 7200 bytes using zlib compression algorithm using dictionary max length of 1.5 MB . I find zlib is slow. Can anyone recommend me a... (3 Replies)
Discussion started by: selvarajvss
3 Replies

4. Red Hat

file roller compression problems with 7z

Can some please tell me why I can't make a 7z archive with file roller? I have already installed p7zip, p7zip-plugins, and 7za. I don't understand what the problem is. I can make a 7z archive from the command line with no problems. I keep getting this message but it doesn't tell me what the error... (0 Replies)
Discussion started by: cokedude
0 Replies

5. Shell Programming and Scripting

file compression

I'am looking for script (or tool) that would compress all files with given extension in all subdirectory. Important part is that every one file have to end in separate archive whit it's own name. Eaven if I could point multiple file in one directory and compress them it would be ok. I' am... (1 Reply)
Discussion started by: Demerzel
1 Replies

6. Linux

Clearning space - File compression issue

Hi, We have access to 2 filesystems: Filesystem Size Used Avail Use% Mounted on /dev/mapper/system-oraoid 30G 30G 119M 100% /app /dev/mapper/system-tmp 2.0G 442M 1.6G 22% /tmp As you can observe the file system on /app is full. In order to recover... (2 Replies)
Discussion started by: animesh303
2 Replies

7. UNIX for Dummies Questions & Answers

.z file compression

Hello, I have a .z file which i understand to be UNIX. I'm on PC (no UNIX boxes) and have tried many different unzipping programs to extract this .z file, but only PicoZip has allowed me to view what is inside (telling me, i think, that it's not corrupt), but i have not been able to extract... (3 Replies)
Discussion started by: Gonecat
3 Replies

8. UNIX for Dummies Questions & Answers

file compression

Is it possible to unzip / compress a file that was zipped using WinZip? thanks, kristy (2 Replies)
Discussion started by: kristy
2 Replies
Login or Register to Ask a Question