Extract a tar file to a different folder
Due to filesystem space issues, I had to upload a tar file to filesystem A but needed to extract it on filesystem B.
The tar file was less than the size of filesystem A. The tar file was less than the size of filesystem B. However, doubling the size of the tar file was greater than the size of filesystem A. Also, doubling the size of the tar file was greater than the size of filesystem B. That is, the extracted contents of the tarball should be the same size as the tarball itself; and the tar file is not deleted as a result of the extraction process.
In other words, I couldn’t do the typical upload to filesystem A and extract to filesystem A. I also couldn’t set the directory path when creating the tarball since that path didn’t exist on the destination server (and also couldn’t be created — the tar was created from a DVD).
LinuxQuestions.org provided the answer. I actually needed to do this on a Solaris 10 system and it worked fine.
cd /path/to/where/files/are/required
cat /path/to/file.tar | tar xf -
Although, I would do this command instead
– to add verbosity (the v) so I could monitor easier
– and throw it in the background (the &) so if my network connection dropped it would still run fine
cat /path/to/file.tar | tar xvf - &
Here’s a good site with basic info on how to use tar if you need more help.