How to untar a file in another directory other then current directory.
hi. I've searched on here and looked in the tar manpage and couldn't find what i was looking for. I was wondering how you can choose to unpack the contents of a tar file to another directory other then the current directory. Do you use the -C option or is that for chosing a directory to tar? thanks for any help in advance.
|
Here is what I found from the manpage:
Code:
-C (or --directory) Change to directory before processing the remaining arguments. |
thanks. I saw that too but when i tried it the directory i tried was long so the -xjvf options i used was split so vf was on another line. I got an error that said this option needs the f switch so i thought it meant i needed it because it thought i was trying to tar the directory. In that situation how would i let tar know that it is all one command? thanks for your help.
|
have you tried:
Code:
tar -xjvf -C DIRECTORY file.tar |
no i tried tar -C /path/to/directory -xzvf file.tar.gz. i wasn't sure if you needed to put the -C option before or after the options or if it mattered.
|
i'm just wondering, why do you need to do that step?
won't it be easy to just go to the directory where you want to untar the package and then give the command from there? or is it that you are using this command in a script? |
yeah it would be good for a script but i was untarring a skin for gmplayer and i didn't want to keep the tar file in the directory for the skin but wanted to keep the tar file around.
|
Theoretically the order shouldn't matter, but the convention is
utilname then flags-without-args then flag-with-arg flag-with-arg . . etc |
untar a file in another directory
I arrive here looking for the same answer... trying what you suggested, finally I found:
tar -C DIRECTORY -xvf file.tar example I want to extract dat-5031.tar in /usr/local/uvscan/ tar -C /usr/local/uvscan/tmp/ -xvf /datos/updates/dat-5031.tar Hope this helps... Moy |
All times are GMT -5. The time now is 09:05 PM. |