is there a way to achieve this with compress?

I'm trying to figure out how I can get an equivalent output to a text file such as if I use

gunzip -l filename

in that gunzip will output the previous file size and the compressed size and the ratio...

is there a way to achieve this with compress and zip?

i am very new at shell scripting and i seem to be getting documentation eyes but little result...

if anyone could offer a bit of quick advice I would greatly appreciate it, thanks.

at the moment I have this piece of code...

gzip helpme
gunzip -l helpme > file
gunzip helpme
compress helpme
gunzip -l helpme >> file
gunzip helpme
zip helpme
zip helpme.zip helpme
gunzip -l helpme.zip >> file
gunzip helpme.zip

as you can see I am simply compressing and decompressing this helpme file three times - gzip, compress and zip - and am trying to get their respective before and after and compression percentage for comparison. I'll use awk later to display it.

So my question is really how do I get over the fact that gunzip -l outputs non gzip files as uncompressed -1 and ratio 0.0%?

If anyone could steer me on course with this I would greatly appreciate it. I'm determined to get on top of this and just have the feeling I'm missing something.

If you are trying to compress an already compressed file you don't gain much, in fact it is possible to lose - in the sense that the compressed compressed file is larger than the compressed file.

try gzip -9 <filename>

to get maximum compression.

If you are trying archive a bunch of files, tar them first, then compress the tarball. tar will allow you to archive .gz files.

sorry I must not have explained properly... all I am trying to do at this point is compress using 3 ways... zip, gzip and compress... and output the results into a file for comparison... which I will use awk to output the results sorted by best compression...

... a single file only

this is just an exercise and I'm not looking for code but rather general advice on how to go about it

thanks for the response anyway :wink: