Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 10-01-2003, 08:28 AM   #1
Registered: Aug 2003
Posts: 55

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


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 08:33 AM.
Old 10-01-2003, 08:49 AM   #2
Registered: Sep 2003
Location: Denmark
Distribution: FreeBSD
Posts: 110

Rep: Reputation: 15
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.

Old 10-01-2003, 08:57 AM   #3
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, 07:07 AM   #4
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
#tar zxvf *.tar.gz
#tar zxvf filename.tgz
Old 10-02-2003, 07:37 AM   #5
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.

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

Rep: Reputation: 0
This worked for me


for a in `ls -1 *.tar.gz`; do tar -zxvf $a; done
Old 07-22-2009, 11:03 AM   #7
Registered: Feb 2008
Location: coevorden
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!


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

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

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