LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 02-12-2006, 08:07 AM   #1
grapnell
Member
 
Registered: Mar 2004
Posts: 48

Rep: Reputation: 15
Lightbulb un-TARring a bunch of files at once


Hi all,
I hope this is a simple question, but I have searched high and low and haven't found an answer. Is there a way to un-tar a bunch of tar.gz files at one time in a directory? I have about 500 tar.gz files that I want to untar, but it will only let me do it one file at a time (from the command line) e.g. if I tar -xzvf *.tar.gz, it just tells me that blah blah blah is not found in the archive. Any suggestions? the man page was no help.
Thanks in advance,
Jeff
 
Old 02-12-2006, 08:34 AM   #2
dive
Senior Member
 
Registered: Aug 2003
Location: UK
Distribution: Slackware
Posts: 3,467

Rep: Reputation: Disabled
Hi, somthing like this should do it:

First do ls > filelist
Then make a script

Code:
#!/bin/bash
gawk -F= '

function untar()
{
print "tar -xzvf " $1 | "sh";
}
{
if($1 != "filelist") untar()
}

END { close("sh") }' filelist
chmod +x it and run in same folder

Last edited by dive; 02-12-2006 at 08:42 AM.
 
Old 02-12-2006, 08:35 AM   #3
grapnell
Member
 
Registered: Mar 2004
Posts: 48

Original Poster
Rep: Reputation: 15
thanks that worked great, but it still seems there should be an easier way to do it.

Thanks for your help this will at least help me out now.
Jeff
 
Old 02-12-2006, 08:50 AM   #4
dive
Senior Member
 
Registered: Aug 2003
Location: UK
Distribution: Slackware
Posts: 3,467

Rep: Reputation: Disabled
Yes I had the same problem with tar but didn't find an easy way out, but if you cp it to a dir in your path it should work just by typing the command, so long as fileist exists in the working dir
 
Old 02-12-2006, 09:07 AM   #5
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 61
How about something like this...

for i in *.gz; do tar -xzvf $i; done
 
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
un-TARring a bunch of files at once grapnell Linux - General 2 02-12-2006 09:18 AM
Need to chown a bunch of remote files. Kbear? $ftp? asktoby Linux - Software 0 12-06-2004 10:27 AM
Help I need help tarring multiple files in multiple directories VisionZ Linux - Newbie 28 03-25-2004 05:25 PM
Need helpThis script erased a bunch of my files HELP VisionZ Linux - Newbie 12 03-25-2004 10:02 AM
un-tarring multiple files phil1076 Linux - General 19 12-18-2003 02:03 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:17 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