GZIP can be used to compress individual files sure... but most of the time you'll see minimal amounts of disk-space savings. Files that take up 1 sector will consume 1-full-sector of disk space, even if the file is less than the sector-size. (i.e. sector-size = 16kb, the file is 8kb... 'compressed' is 5kb... still takes up 16kb of "disk-space") The power of gzip is much more evident when you combine all the files into a single file (using tar typically) and then compress the singular archive. (combined, the "archive" can take all the files and combine them into 1 singular file on the disk... which will have less "dead-space" between sectors)
For example:
tar -czf compressed_archive.tgz folder/*
tar -c
creates an archive, z
uses gzip compression, and f
writes the results to a file called compressed_archive.tgz. You can also switch to using bz2 compression (which does better in many cases) by simply switching the z
switch to a j
.
If you want to then extract files from the archive, you can simply do the reverse
tar -zxf compressed_archive.tgz
which would x
extract the files that were z
gzip'd, f
from the archive file called compressed_archive.tgz.