LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 11-07-2006, 04:33 PM   #1
prophoto
Member
 
Registered: Jul 2006
Posts: 30

Rep: Reputation: 0
tar -zxvf foo.tar.gz creates all .gz files


I am attempting to untar a backup, and each file is is still compressed after I use:

tar -zxvf foo.tar.gz

There are over 1000 files in the tarball so unziping each one is out of the question. Help!
 
Old 11-07-2006, 04:56 PM   #2
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
Can you post the results of the following command:
Code:
tar ztvf foo.tar.gz |head -n 20
 
Old 11-07-2006, 08:24 PM   #3
prophoto
Member
 
Registered: Jul 2006
Posts: 30

Original Poster
Rep: Reputation: 0
[root@sb subdomains]# tar ztvf foo.tar.gz |head -n 20
drwxr-xr-x root/root 0 2006-10-19 01:21:47 gallery/
drwxr-x--- vtiphoto/psaserv 0 2006-10-12 10:56:14 gallery/httpsdocs/
drwxr-xr-x vtiphoto/psacln 0 2006-03-31 02:25:37 gallery/httpsdocs/img/
drwxr-xr-x vtiphoto/psacln 0 2006-10-12 10:56:14 gallery/httpsdocs/img/glyph/
-rwxr-xr-x vtiphoto/psacln 576 2006-10-12 10:56:14 gallery/httpsdocs/img/glyph/btn_asp_bg.gif.gz
-rwxr-xr-x vtiphoto/psacln 1298 2006-10-12 10:56:14 gallery/httpsdocs/img/glyph/btn_php_bg.gif.gz
-rwxr-xr-x vtiphoto/psacln 1382 2006-10-12 10:56:14 gallery/httpsdocs/img/glyph/btn_python_bg.gif.gz
-rwxr-xr-x vtiphoto/psacln 1342 2006-10-12 10:56:14 gallery/httpsdocs/img/glyph/btn_ssi_bg.gif.gz
-rwxr-xr-x vtiphoto/psacln 425 2006-10-12 10:56:14 gallery/httpsdocs/img/glyph/btn_bg.gif.gz
-rwxr-xr-x vtiphoto/psacln 938 2006-10-12 10:56:14 gallery/httpsdocs/img/glyph/btn_perl_bg.gif.gz
-rwxr-xr-x vtiphoto/psacln 414 2006-10-12 10:56:14 gallery/httpsdocs/img/glyph/btn_bg-disabled.gif.gz
-rwxr-xr-x vtiphoto/psacln 1551 2006-10-12 10:56:14 gallery/httpsdocs/img/glyph/btn_cgi_bg.gif.gz
-rwxr-xr-x vtiphoto/psacln 812 2006-10-12 10:56:14 gallery/httpsdocs/img/glyph/btn_ok_bg.gif.gz
-rwxr-xr-x vtiphoto/psacln 1182 2006-10-12 10:56:14 gallery/httpsdocs/img/glyph/btn_coldfusion_bg.gif.gz
drwxr-xr-x vtiphoto/psacln 0 2006-10-12 10:56:14 gallery/httpsdocs/img/icons/
drwxr-xr-x vtiphoto/psacln 0 2006-10-12 10:56:14 gallery/httpsdocs/img/icons/tabs/
-rwxr-xr-x vtiphoto/psacln 1214 2006-10-12 10:56:14 gallery/httpsdocs/img/icons/tabs/right_on.gif.gz
-rwxr-xr-x vtiphoto/psacln 296 2006-10-12 10:56:14 gallery/httpsdocs/img/icons/tabs/left.gif.gz
-rwxr-xr-x vtiphoto/psacln 174 2006-10-12 10:56:14 gallery/httpsdocs/img/icons/tabs/left_over.gif.gz
-rwxr-xr-x vtiphoto/psacln 209 2006-10-12 10:56:14 gallery/httpsdocs/img/icons/tabs/left_on.gif.gz
[root@sb subdomains]#
 
Old 11-07-2006, 08:38 PM   #4
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
If it unzips each into a new directory, just cd into that directory and do for loop like:

Code:
for FILE in `ls`
   do
     tar xzvf $FILE
done
 
Old 11-07-2006, 08:57 PM   #5
prophoto
Member
 
Registered: Jul 2006
Posts: 30

Original Poster
Rep: Reputation: 0
...There are also many directories, I think my estimate of the number of files is low....
 
Old 11-07-2006, 09:06 PM   #6
konsolebox
Senior Member
 
Registered: Oct 2005
Distribution: Gentoo, Slackware, LFS
Posts: 2,248
Blog Entries: 8

Rep: Reputation: 235Reputation: 235Reputation: 235
What files are you trying to untar? Or are you trying to uncompress the backup files one by one?
 
Old 11-07-2006, 09:41 PM   #7
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
Quote:
Originally Posted by prophoto
...There are also many directories, I think my estimate of the number of files is low....
Then do a find on them and -exec tar -xzvf or pipe to xargs to untar them.
 
Old 11-07-2006, 10:01 PM   #8
prophoto
Member
 
Registered: Jul 2006
Posts: 30

Original Poster
Rep: Reputation: 0
trickykid:

I'd love to! Can you help out the n00b and and give me step by step?
 
Old 11-08-2006, 01:02 AM   #9
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
Quote:
Originally Posted by prophoto
trickykid:

I'd love to! Can you help out the n00b and and give me step by step?
1. cd into the directory where all the tar.gz files are located.
2. Run:

find . -type f -name *.tar.gz -exec tar xzvf {} \;

That should find all the tar.gz including those in subdirectories and unzip them all.
 
Old 11-08-2006, 03:46 AM   #10
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
First, de-tar the file:
Code:
tar zxvf foo.tar.gz
...now you have all these .gz files we have to gunzip them. This method will recurse into sub-directories, and will work even if the file/directory names include spaces and other weird characters. It also prints verbose information about what it is doing, which is nice if there is a really large amount of work to do because you can see that it's still working even if it takes a while:
Code:
find . -type f -iname \*.gz -print0 |xargs -0 gunzip -v
If you have multiple processors, you can use the -P *max-procs* option to xargs to run multiple instances of gunzip in parallel. There's no point if you only have one CPU (in fact it'll probably run slower). You should also leave some CPU for IO work. So if you have 4 CPUs, try:
Code:
find . -type f -iname \*.gz -print0 |xargs -0 -P 3 gunzip -v
...which will tun 3 parallel gunzip's together, leaving one CPU for IO and other work. Of course, this is only really going to be noticeable if the amount of gunzipping is very large...
 
Old 11-08-2006, 09:40 AM   #11
prophoto
Member
 
Registered: Jul 2006
Posts: 30

Original Poster
Rep: Reputation: 0
I'll try it now and let you know....Thanx!
 
Old 11-09-2006, 06:27 PM   #12
prophoto
Member
 
Registered: Jul 2006
Posts: 30

Original Poster
Rep: Reputation: 0
Wow....worked like a charm...THANX!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how can i decompress this tar.tar file? hmmm sounds new.. tar.tar.. help ;) kublador Linux - Software 14 10-25-2016 02:48 AM
a tough question 4 u, problem in extracting tar & tar.gz files p_garg Linux - General 5 11-08-2010 11:02 AM
how-to: tar -zxvf multiple files at once stevesk Linux - Newbie 3 02-15-2006 08:59 AM
tar zxvf and slackware 10.0 paul62 Slackware 5 09-25-2004 11:25 AM
tar -zxvf *.tgz adam_boz Linux - Newbie 9 09-03-2002 04:25 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:42 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration