extraction of directory and below using gnu tar

 
Thread Tools Search this Thread
Homework and Emergencies Emergency UNIX and Linux Support extraction of directory and below using gnu tar
# 1  
Old 02-26-2012
extraction of directory and below using gnu tar

i need to restore everything in a certain directory and lower. I have a tgz archive of all of the files, and i need to restore everything in /user/home/xxxx/ and below. this is a users home directory. this is a dumb question and i know when i see the answer i am going to say DUH, but i am drawing a blank right now.

Last edited by frankkahle; 02-26-2012 at 04:55 PM..
# 2  
Old 02-26-2012
Assuming that tar stripped the leading slants when it created the archive, this should work:

Code:
cd /some/work/directory
gzip -dc file.tgz | tar -xf - user/home/xxxx

If your version of tar supports -z, then
Code:
tar -xzf file.tgz user/home/xxxx

I always restore into a working directory so as not to accidentally overlay something. Once the files are restored, you can copy/move them as needed.
This User Gave Thanks to agama For This Post:
# 3  
Old 02-26-2012
Quote:
Originally Posted by agama
Assuming that tar stripped the leading slants when it created the archive, this should work:

Code:
cd /some/work/directory
gzip -dc file.tgz | tar -xf - user/home/xxxx

If your version of tar supports -z, then
Code:
tar -xzf file.tgz user/home/xxxx

I always restore into a working directory so as not to accidentally overlay something. Once the files are restored, you can copy/move them as needed.
yes thank you , i was not leaving off the leading /, so it wasnt finding anything.,....
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Speed up extraction od tar.bz2 files using bash

The below bash will untar each tar.bz2 folder in the directory, then remove the tar.bz2. Each of the tar.bz2 folders ranges from 40-75GB and currently takes ~2 hours to extract. Is there a way to speed up the extraction process? I am using a xeon processor with 12 cores. Thank you :). ... (7 Replies)
Discussion started by: cmccabe
7 Replies

2. AIX

GNU TAR vs NATIVE AIX TAR

Hello, Getting this very strange error, made tar/zip through gnu tar GNU Tar ( successful tar and zip without any errors ) /opt/freeware/bin/tar cvf - /oraapp| gzip > /backup/bkp_15_6_16_oraapp.tgz GNU unTar error root@test8:/>gunzip < /config1/bkp_15_6_16_oraapp.tgz |... (5 Replies)
Discussion started by: filosophizer
5 Replies

3. Shell Programming and Scripting

Extraction of .tar.gz creates additional unwanted directories

I'm working on a project that requires me to compress then relocate directories to a different location based on their last date of modification. After running the script I check to see if it worked, and upon unzipping the tar.gz using I created everything that should be there is. I then performed... (4 Replies)
Discussion started by: jrymer
4 Replies

4. UNIX for Advanced & Expert Users

tar and gzip extraction issues

Not sure if this is really in the right forum but here goes.... Looking for a way to extract individual compressed files from a compressed tarball WITHOUT tar -zxvf and then recompressing. Basically we need to be able to chunk out an individual compressed file while it still remains... (6 Replies)
Discussion started by: athos
6 Replies

5. AIX

Tar extraction error in aix 5.3

Hi root@appdr01 #ls -latr total 2887400 drwxr-xr-x 2 root system 256 May 06 11:34 lost+found drwxr-xr-x 34 root system 4096 May 06 11:34 .. drwxr-xr-x 3 root system 256 May 06 12:20 . -rw-r----- 1 root system 1478338560 May 06... (1 Reply)
Discussion started by: samsungsamsung
1 Replies

6. Shell Programming and Scripting

tar command dont tar to original directory

HI, if I have a tarfile called pmapdata.tar that contains tar -tvf pmapdata.tar -rw-r--r-- 0/0 21 Oct 15 11:00 2009 /var/tmp/pmapdata/pmap4628.txt -rw-r--r-- 0/0 21 Oct 14 20:00 2009 /var/tmp/pmapdata/pmap23752.txt -rw-r--r-- 0/0 1625 Oct 13 20:00 2009... (1 Reply)
Discussion started by: borderblaster
1 Replies

7. Shell Programming and Scripting

Help with tar extraction!

I have this tar file which has files of (.ksh, .ini &.sql) and their hard and soft links. Later when the original files and their directories are deleted (or rather lost as in a system crash), I have this tar file as the only source to restore all of them. In such a case when I do, tar... (4 Replies)
Discussion started by: manthasirisha
4 Replies

8. UNIX for Dummies Questions & Answers

Very slow Tar extraction from tape

I'm pulling a 1MB file from tape using tar. It's a 300GB DLT tape and it does have a lot of files on it because it's go the entire OS and Oracle RMAN files and 3000 table exports, but it's taking 2-3 hours to pull this file off of it. Is this type of performance what I should expect? The... (0 Replies)
Discussion started by: citrowske
0 Replies

9. Solaris

GNU tar on SUN 9

I downloaded GNUtar from sunfreeware.con and installed it on a sparc running sun 9. Performed pkgadd -d on the required lib and tar file and everything seemed to be ok. I tried to extract a file from a tar created using the sun version with no success. Tar ran for several hours working on the... (6 Replies)
Discussion started by: thumper
6 Replies

10. UNIX for Dummies Questions & Answers

gnu tar on Solaris 8

Here is how I got where I am: I tried untarring tomcat and at the end of the untar I get the following: So I downloaded GNU tar and did a pkgadd -d, which installed the package. But when I run /usr/local/bin/tar, I get this message: (1 Reply)
Discussion started by: dangral
1 Replies
Login or Register to Ask a Question