I gleaned this info many years ago from various sources. Unfortunately I don't know who all contributed. I simply made myself a text file called "tgz notes" and have kept it all these years for those times when I couldn't remember how I did this.
Read the rest of the article for some different examples of how to use 'tar'.
To tar the current directory into one file and save the new file in the parent directory:
% tar cf - . > ../filename.tarTo then zip the new file:
% cat ../filename.tar | gzip > ../filename.tgzTo do both at the same time:
% tar cf - . | gzip > ../filename.tgzTo extract, first change to the location you want the files (ie. create the outermost directory of the archive and then cd to it) and then:
% zcat /some/path/filename.tgz | tar xvf -So to archive the entire file structure within a directory:
% cd /some/path/directoryYou end up with a new file named /some/path/directory.tgz. Then you do the following to put the directory structure somewhere else:
% tar cf - . | gzip > ../directory.tgz
% cd /new/locationAnd you end up with the identical structure at both places, /some/path/directory and /new/location/directory.
% mkdir new_directory
% cd directory
% zcat /some/path/directory.tgz | tar xvf -
[Editor's note: Although basic for experienced UNIX users, these tar tips should be helpful to those new to this world on the Mac.]

