LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Debian (https://www.linuxquestions.org/questions/debian-26/)
-   -   Extracting a tar ball directly into a directory (https://www.linuxquestions.org/questions/debian-26/extracting-a-tar-ball-directly-into-a-directory-367876/)

kushalkoolwal 09-28-2005 01:21 PM

Extracting a tar ball directly into a directory
 
Ih, I have a very silly question but I admit that I am not able to do that. Here it is
I have image.tar.bz2 file in my home directory which I want to extract into /tmp/test/ directory. And this is how I am approaching right now:
1.cp image.tar.bz2 /tmp/test/
2.cd /tmp/test/
3. tar -xjf image.tar.bz2
4. rm image.tar.bz2

Now what I would like is to extract the files directly into /tmp/test directory from the directory where image.tar.bz2 files resides(in this case it is my home directory) without first copying the tar ball(step1) and then removing the tar ball(step 4).

Thanks

david_ross 09-28-2005 01:43 PM

You should be able to use either:
cd /tmp/test
tar -xjf /path/to/image.tar.bz2

or:
tar -C /tmp/test -xjf /path/to/image.tar.bz2

kushalkoolwal 09-28-2005 01:47 PM

Yes that works. Actually just before reading your post I read the man page for tar carefully and I found the -C option. Thank for looking inot this.

Kushal


All times are GMT -5. The time now is 10:35 AM.