09-04-2006
Shell Script - compression
Hello all, i am a complete beginner when it comes to unix and shell scripting.
I want to be able to compress a file (ff) with a shell script for example the command would look like
compress.sh ff
then with the script have the file compressed using the zip, gzip and compress commands.
I want to have the size of the file and the size of hte compressed file outputed to the screen with the three programs something like this
gzip 17375 5550 68.1
zip 17375 5665 67.4
compress 17375 7641 56.0
each of the values should be in columns also.
with the last column being the compression ratio. those numbers are just examples.
I'm having trouble storing the value of the filesize in a variable and also how to get the data displayed like I would like it above in columns.
I was thing of having the example stored to a file as then I can have the 3rd column sorted by the compression of the file.
Any help would be greatly appreciated in how to ge this done.
Cheers
Tony
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
I've noticed bzip2 gives a little bit better compression than gzip. So...I'm curious...what's gives the best compression out of all the compression utilities?
Thanks! (6 Replies)
Discussion started by: jalburger
6 Replies
2. UNIX for Dummies Questions & Answers
I have heard that bz2 compression a relatively new compression encoding algorithm, far superior to tar and gz. I also remember that I downloaded a FreeBSD LiveCD a while back that was only a couple hundred megs instead of the usual 650ish using bz2 - big difference, I'd say. But to the point, what... (4 Replies)
Discussion started by: Phobos
4 Replies
3. Shell Programming and Scripting
in the instance of a file compressed with compress to a .Z extension...
how would I, in the Bourne Shell, capture its compression ratio? Gunzip returns -1 and I'd then gone down the track of roughly calculating the ratio (not including time) manually.
Until I found out the Bourne Shell... (7 Replies)
Discussion started by: nortypig
7 Replies
4. UNIX for Advanced & Expert Users
Hi everybody,
Does anybody know,whether linux-2.4.20-8 supports predictor1 compression in PPP protocol support,as i was able to see there were only two compression techniques that r being supported i.e bsd and
deflate compression from "make menuconfig" under network device... (0 Replies)
Discussion started by: sriram.ec
0 Replies
5. UNIX for Dummies Questions & Answers
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
6. UNIX for Dummies Questions & Answers
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... (6 Replies)
Discussion started by: Spaulds
6 Replies
7. Shell Programming and Scripting
Hi Guys,
totally new to scripting.
I have a huge list of foleders.
I want to tar the contents of each folder inside the same folder and the name of the tar file is the same name as the folder.
how would I go about this in scirpt?
cheers
Viper (3 Replies)
Discussion started by: brownviper1966
3 Replies
8. Shell Programming and Scripting
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
9. Linux
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
10. UNIX for Advanced & Expert Users
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
ZNEW(1) General Commands Manual ZNEW(1)
NAME
znew - recompress .Z files to .gz files
SYNOPSIS
znew [ -ftv9PK] [ name.Z ... ]
DESCRIPTION
Znew recompresses files from .Z (compress) format to .gz (gzip) format. If you want to recompress a file already in gzip format, rename
the file to force a .Z extension then apply znew.
OPTIONS
-f Force recompression from .Z to .gz format even if a .gz file already exists.
-t Tests the new files before deleting originals.
-v Verbose. Display the name and percentage reduction for each file compressed.
-9 Use the slowest compression method (optimal compression).
-P Use pipes for the conversion to reduce disk space usage.
-K Keep a .Z file when it is smaller than the .gz file
SEE ALSO
gzip(1), zmore(1), zdiff(1), zgrep(1), zforce(1), gzexe(1), compress(1)
BUGS
Znew does not maintain the time stamp with the -P option if cpmod(1) is not available and touch(1) does not support the -r option.
ZNEW(1)