Solaris does not ship with the GNU tar and by default, the tar command in Solaris does not allow you to create gzip or bzip2 files, but only pure tarballs. You will need to create a tar file first and then compress the tarball with the gzip command.
But, we can use UNIX pipes and redirects to create a tar.gz file in a single command in Solaris. This is how we do it:
tar cf - foo | gzip -c > foo.tar.gz
We are trying to tar the foo file/directory, pipe the output to gzip, tell gzip to zip the contents from stdin and print the output to stdout and redirect the stdout to a file called foo.tar.gz!
To extract a tar.gz file in Solaris, run the commands in reverse order.
gunzip -c foo.tar.gz | tar xf -
We tell gunzip to extract foo.tar.gz to stdout, pipe the output to tar and instruct tar to extract the tarball from stdin.