Is there a way to print the decompressed size of a .bz2 file without actually decompressing the entire thing?
As noted by others, bzip2 doesn't provide much information. But this technique works -- you will have to decompress the file, but you won't have to write the decompressed data to disk, which may be a "good enough" solution for you:
$ ls -l foo.bz2 -rw-r--r-- 1 ~quack ~quack 2364418 Jul 4 11:15 foo.bz2 $ bzcat foo.bz2 | wc -c # bzcat decompresses to stdout, wc -c counts bytes 2928640 # number of bytes of decompressed data
You can pipe that output into something else to give you a human-readable form:
$ ls -lh foo.bz2 -rw-r--r-- 1 quack quack 2.3M Jul 4 11:15 foo.bz2 $ bzcat foo.bz2 | wc -c | perl -lne 'printf("%.2fM\n", $_/1024/1024)' 2.79M