Compressing files with gzip

The command gzip can be used to compress files in order to save space. For example:

gzip *.data

compresses all files with extension .data in the current directory. It adds the extenson.gz to files it compresses. To uncompress the files, use:

gunzip *.data.gz

The gzip command is often combined with tar by using the z option to tar. So we can use:

tar czvf cs253.tar.gz cs253

to create a tarball that is also compressed. The convention is to name the compressed tarball with the extension .tar.gz. To unpack a compressed tarball, we would use the z option as well. For example:

tar xzvf cs253.tar.gz

Another common extension for compressed tar files is .tgz. For example:

tar czvf cs253.tgz cs253