Get the Best Compression Possible with zip-[0-9]It's possible to adjust the level of compression that zip uses when it does its job. The zip command uses a scale from 0 to 9, in which 0 means "no compression at all" (which is like tar, as you'll see later), 1 means "do the job quickly, but don't bother compressing very much," and 9 means "compress the heck out of the files, and I don't mind waiting a bit longer to get the job done." The default is 6, but modern computers are fast enough that it's probably just fine to use 9 all the time. Say you're interested in researching Herman Melville's Moby-Dick, so you want to collect key texts to help you understand the book: Moby-Dick itself, Milton's Paradise Lost, and the Bible's book of Job. Let's compare the results of different compression rates. $ ls -l -rw-r--r-- scott scott 102519 job.txt -rw-r--r-- scott scott 1236574 moby-dick.txt -rw-r--r-- scott scott 508925 paradise_lost.txt $ zip -0 moby.zip *.txt adding: job.txt (stored 0%) adding: moby-dick.txt (stored 0%) adding: paradise_lost.txt (stored 0%) $ ls -l -rw-r--r-- scott scott 102519 job.txt -rw-r--r-- scott scott 1236574 moby-dick.txt -rw-r--r-- scott scott 1848444 moby.zip -rw-r--r-- scott scott 508925 paradise_lost.txt $ zip -1 moby.zip *txt updating: job.txt (deflated 58%) updating: moby-dick.txt (deflated 54%) updating: paradise_lost.txt (deflated 50%) $ ls -l -rw-r--r-- scott scott 102519 job.txt -rw-r--r-- scott scott 1236574 moby-dick.txt -rw-r--r-- scott scott 869946 moby.zip -rw-r--r-- scott scott 508925 paradise_lost.txt $ zip -9 moby.zip *txt updating: job.txt (deflated 65%) updating: moby-dick.txt (deflated 61%) updating: paradise_lost.txt (deflated 56%) $ ls -l -rw-r--r-- scott scott 102519 job.txt -rw-r--r-- scott scott 1236574 moby-dick.txt -rw-r--r-- scott scott 747730 moby.zip -rw-r--r-- scott scott 508925 paradise_lost.txt In tabular format, the results look like this:
The results you see here would vary depending on the file types (text files typically compress well) and the sizes of the original files, but this gives you a good idea of what you can expect. Unless you have a really slow machine or you're just naturally impatient, you should just use -9 all the time to get the maximum compression. Note If you want to be clever, define an alias in your .bashrc file that looks like this: alias zip='zip -9' That way you'll always use -9 and won't have to think about it. |