tar - extract to different directory
Hi there, if i am in /opt and i want to extract /data/package.tar to /usr, how do I do it...How can I extract to a directoory that im not currently in ???
eg ....(I thought this would work but it doesnt) #cd /opt # tar xvf /data/package.tar /usr cheers |
Reading through the man page for tar, I don't think you can do this. If you want to extract the files from a tarfile "foo.tar", you would simply go to the directory that you want to use as a starting point and then extract it from there. For instance, if I have a tarfile named "foo.tar" in my home directory "/home/bar", and I want to extract that tar file into /opt, I would do the following:
# cd /opt # tar xvf /home/bar/foo.tar When you tried to do "tar xvf /data/package.tar /usr", as far as tar was concerned what you were asking to do was extract the file "/usr" from the tarfile package.tar. This may or may not have worked, depending on what was actually in the package.tar file. :) |
Quote:
Code:
tar xvf /data/package.tar -C /usr |
extract tar file to a different folder
I tried this:
Code:
tar xvf /data/package.tar -C /usr This did work though, and might be more portable: Code:
cd /path/to/where/files/are/required |
Quote:
|
All times are GMT -5. The time now is 11:53 AM. |