Compression and decompression in the same script

Hi Guys,

I'm just wondering how to compress and decompress a file in the same script using multiple programs, and can it be done in one line?

e.g gzip file && gunzip file
bzip2 file && bunzip file

I tried this and a few other combinations but it doesn't seem to work. Any thoughts?

Cheers Spaulds

gzip file && gunzip file

should just work.
Alternatively:

gzip < file | gunzip > file1

Cheers, there must be an error in my script.

---------- Post updated at 01:34 AM ---------- Previous update was at 01:20 AM ----------

Sweet, got it working!

Can you display the sorterd attributes of the compression programs with somethng like:

awk'{$1 $2 $3}' | sort -n

Please elaborate on what you are looking for.

looking to display:

-compression program | compression size | decompression size | compression ratio

The compression ratio will equal the (de)compression one for lossless algorithms like gzip and bzip.
The decompressed file size will equal the original file size.

To get statistics, use the -v option.

No probs, cheers for the help!