How to expand .tar.gz files

 

Intoduction:
	A few weeks ago, I posted an updated version of the "smokers problem" to
the page here. Since there were several source files involved in the completion
of this problem, I decided to aggregate them all into one file, suitable for
downloading. I chose to do this in the UNIX-way, which meant first using
tar (Tape Archive) to store all of the individual source files into
one large 'archive' file. Then, I compressed this archive file using the GNU
gzip program.

	I didn't think anything about this after it was done, but since then,
I've been getting questions about this file, so I guess I'd better explain how
to unpack it.
The 'Normal' Way:
First, decompress the file:

	gzip -d smokers_problem_example.tar.gz

This command will expand the file, and leave the original as the result. It
automatically strip the '.gz' extension from the name.

Next, create a directory in order to store the contents of the tar archive.
For example, execute the following:

	mkdir smokers_example

Now, change to that directory:

	cd smokers_example

Finally, un-tar the archive, leaving the files in this directory:

	tar -xvf ../smokers_problem_example.tar

When finished, you should have the following files in your directory:

	Makefile
	agent.c
	smoker.c
	smoking_main.c
	smoking_main.h
The 'Pro' Way:
If you have access to GNU tar (installed in /usr/local/bin), then you
can simply execute the following:

	tar -zxvf smokers_problem_example.tar.gz

With the 'z' option, GNU tar will automatically un-gzip the file, and then
un-tar it (the 'x' option).