extract tar.gz files


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers extract tar.gz files
# 1  
Old 05-03-2005
Question extract tar.gz files

Hi All,


I want to extract my *.tar.gz files like below;

01.tar.gz
02.tar.gz
03.tar.gz
04.tar.gz
05.tar.gz
06.tar.gz
..
..
31.tar.gz

how can I do it by automatically using a command ??

thanks

Alice
# 2  
Old 05-03-2005
Code:
for file in *.tar.gz; do
   gunzip -c $file | tar xf -
done

# 3  
Old 05-03-2005
Quote:
Originally Posted by alisevA3
how can I do it by automatically using a command ??
thanks
Alice
It's always worthwhile posting the output of uname -a so that we can see what OS you're using - for example, if you're using Linux you can use the z option to tar and omit the need for gunzip -c (or gzcat).

Cheers
ZB
# 4  
Old 05-04-2005
When you have a file containing the filenames, eg

# cat filelist
file1.tar.gz
file2.tar.gz
file45.tar.gz
...

# for x in `cat filelist`; do gzcat $x | tar xf -; done
# 5  
Old 05-04-2005
Quote:
Originally Posted by networkfre@k
When you have a file containing the filenames, eg

# cat filelist
file1.tar.gz
file2.tar.gz
file45.tar.gz
...

# for x in `cat filelist`; do gzcat $x | tar xf -; done
Or to avoid the UUOC and use a while loop (which is faster anyway)
Code:
while read file; do
  gunzip -c $file | tar xf -
done < filelist

Also, it's always safer to use gunzip -c over gzcat as gzcat may not be present on all systems - gunzip -c will be more portable.

Cheers
ZB
# 6  
Old 05-04-2005
Quote:
Originally Posted by reborg
Code:
for file in *.tar.gz; do
   gunzip -c $file | tar xf -
done

Accepted answer. Smilie
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Do I need to extract the entire tar file to confirm the tar folder is fine?

I would like to confirm my file.tar is been tar-ed correctly before I remove them. But I have very limited disc space to untar it. Can I just do the listing instead of actual extract it? Can I say confirm folder integrity if the listing is sucessful without problem? tar tvf file1.tar ... (1 Reply)
Discussion started by: vivien_chu
1 Replies

2. Shell Programming and Scripting

Extract files from tar ball without directory structure

Hi, I have tar filw which has multiple directories which contain files. When i extract using tar -xf the directory structure also get extracted. I require only files and not directory structures as there will be overhead of moving the files again. So i searched here and got a solution but... (4 Replies)
Discussion started by: chetan.c
4 Replies

3. Shell Programming and Scripting

Extract contents of tar ball without extracting files

Hi, I'm using a tar command tar -xOvf /home/mytar.tar My intention is to extract data in files which are inside various directories, without extracting files to the disk. Is this the best way to achieve it? Thanks, Chetan (3 Replies)
Discussion started by: chetan.c
3 Replies

4. Shell Programming and Scripting

tar command to explore multiple layers of tar and tar.gz files

Hi all, I have a tar file and inside that tar file is a folder with additional tar.gz files. What I want to do is look inside the first tar file and then find the second tar file I'm looking for, look inside that tar.gz file to find a certain directory. I'm encountering issues by trying to... (1 Reply)
Discussion started by: bashnewbee
1 Replies

5. Emergency UNIX and Linux Support

Extract particular folder from a .tar format files.

Hi All- I want to extract a particular folder from .tar format files. For example: File Name: backup.tar The backup.tar contains the below folders & files. 1) /root_folder/Folder1/Folder1-1/* 2) /root_folder/Folder1/Folder1-2/* 3) /root_folder/Folder2/Folder2-1/* 4)... (5 Replies)
Discussion started by: k_manimuthu
5 Replies

6. Solaris

How to extract files from a tar file without creating the directories?

Hello all. I have a tar file that contains a number of files that are stored in different directories. If I extract this tar file with -xvf , the directories get created. Is there a way to extract all of the files into one directory without creating the directories stored in the tar file. (9 Replies)
Discussion started by: gkb
9 Replies

7. Linux

extract glibc-2.3.2.tar.tar

Hi, how can I extract glibc-2.3.2.tar.tar file ? I used tar -xf but does not work. Thank you. (4 Replies)
Discussion started by: big123456
4 Replies

8. Shell Programming and Scripting

extract one file form .tar.gz without uncompressing .tar.gz file

hi all, kindly help me how to extract one file form .tar.gz without uncompressing .tar.gz file. thanks in advance bali (2 Replies)
Discussion started by: balireddy_77
2 Replies

9. UNIX for Dummies Questions & Answers

extract tar files without creating directory

I received a tar file of a directory with 50,000 files in it. Is it possible to extract the files in the tar file without first creating the directory? ie. Doing tar -xvf filename.tar extracts as follows: x directory/file1.txt x directory/file2.txt . . . I would like to avoid... (4 Replies)
Discussion started by: here2learn
4 Replies

10. UNIX for Dummies Questions & Answers

cant extract files from a tar file

hi everyone i have a tar file which was in AIX box. its 300mb. i cant untar in windowsxp home. I just get an empty folder with no files when i extract. i dont get any bad header or any such error. i am using IZARC which is a freeware. Not sure if i should try winzip or winrar. any help (2 Replies)
Discussion started by: bryan
2 Replies
Login or Register to Ask a Question