Thursday, June 04, 2009

How to create a zipped tar file?

This is very similar to creating a tar file. The only difference is you change the file name and add a new command line option. In the last post we created a tar file of all the html files in a directory. Let's do this again only this time, we'll create a gzipped tar file.

/my/web/root> tar -cvzf mywebroot.tar.gz *.html

Note the new option (z) and the new file extention (.tar.gz)

The ability to create zipped tar files is a handy convenience, otherwise you would find yourself zipping up the tar files in an extra step. It's just easier to do it this way.

To view the contents of a zipped tar file is just as easy:

/my/web/root> tar -tzvf mywebroot.tar.gz

Give it a try!