RE: How to compress files by using shell scripting
Though the explanations given are very good but in real time environment where the file size runs into MBs of data the proper way would be
1: If its a single file then gzip and compress and pack will serve the purpose. Out of these compress gives the more desired results These commands use different compression algorithms take different amounts of time and reduce files by different amounts.
In general these commands can reduce the size of a file by 50-75 .
Command
Syntax
File Produced
gzip
gzip
.gz
zip
zip
.zip
compress
compress
.Z
pack
pack
.z
2: In case of a directory with a content of directory tree inside its better to first tar the main directory and then use compress option to reduce the size.