LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 10-01-2003, 07:28 AM   #1
zoomzoom
Member
 
Registered: Aug 2003
Posts: 55

Rep: Reputation: 15
How to untar all tar-files in a directory?


Hi

Although its a somehow stupid question:

can anyone give me the right tar command to extract all file of a directory? i tried 'tar -xzvf *.tar.gz' and many others but none worked... (i also couldnt find what i need in the manpage)

Thank you

Last edited by zoomzoom; 10-01-2003 at 07:33 AM.
 
Old 10-01-2003, 07:49 AM   #2
WiZaC
Member
 
Registered: Sep 2003
Location: Denmark
Distribution: FreeBSD
Posts: 110

Rep: Reputation: 15
Examples:
tar -cf archive.tar foo bar # Create archive.tar from files foo and bar.
tar -tvf archive.tar # List all files in archive.tar verbosely.
tar -xf archive.tar # Extract all files from archive.tar.

WiZaC
 
Old 10-01-2003, 07:57 AM   #3
jogar
LQ Newbie
 
Registered: Sep 2003
Location: Yorktown, VA
Distribution: Mandrake 10
Posts: 8

Rep: Reputation: 0
Try (in bash):

for a in `ls -1 *.tar.gz`; do gzip -dc $a | tar xf -; done
 
Old 10-02-2003, 06:07 AM   #4
farhanagri
LQ Newbie
 
Registered: Sep 2003
Location: Bangladesh
Distribution: as i have 3 pc i use slackware redhat and suse linux
Posts: 3

Rep: Reputation: 0
try
#tar zxvf *.tar.gz
#tar zxvf filename.tgz
 
Old 10-02-2003, 06:37 AM   #5
yapp
Member
 
Registered: Apr 2003
Location: Netherlands
Distribution: SuSE (before: Gentoo, Slackware)
Posts: 613

Rep: Reputation: 30
extract one tar.gz:
* tar zxf filename.tar.gz

extract a certain file:
* tar zxf filename.tar.gz requested-files..

That's why your *.tar.gz doesn't work.
If you type "echo *" you'll see what every shell does, and why tar doesn't see the "*.tar.gz" you've typed.

Code:
for filename in *.tar.gz
do
  tar zxf $filename
done
 
Old 05-27-2007, 03:50 PM   #6
sthneed
LQ Newbie
 
Registered: May 2007
Posts: 1

Rep: Reputation: 0
This worked for me

bash:

for a in `ls -1 *.tar.gz`; do tar -zxvf $a; done
 
Old 07-22-2009, 10:03 AM   #7
R03L
Member
 
Registered: Feb 2008
Distribution: mepis, ubuntu server ed. Debian. Redhat. Fedora, centos, LFS
Posts: 211

Rep: Reputation: 31
for i in *.tar.gz

for i in *.tar.gz; do echo working on $i; tar xvzf $i ; done

works for me!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Whats the command to untar files that end in .tar.bz2? BaZiL Linux - Newbie 3 06-20-2007 10:51 AM
untar a list of tar files? Rotwang Linux - General 6 10-10-2006 01:34 PM
Getting problem when untar the .tar.gz file? ramakumard77 Linux - General 2 11-29-2004 11:15 AM
Bash script (untar *.tar files and then cd to the untared dir) k0ljat Linux - Newbie 2 12-30-2003 05:57 AM
Untar filename.tar.tar Dr.Swing Linux - Newbie 12 09-27-2002 07:10 AM


All times are GMT -5. The time now is 02:03 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration