How do I use gunzip and tar to extract my tar.gz file to the specific directory I want?
You can do a single tar
command to extract the contents where you want:
tar -zxvf path_to_file -C output_directory
As explained in the tar
manpages:
-C directory, --cd directory, --directory directory
In c and r mode, this changes the directory before adding the following files. In x mode, change directories after opening the archive but before extracting entries from the archive.
As you added that you are using Solaris, I think you could try:
gunzip -dc path_to_file | tar xf - -C path_to_extract
Does this do what you want?
tar xzvf file.tar.gz -C /target/directory