Extract multiple tar

I want to extract multiple tar.gz files from terminal.
I run:
Code:
sudo tar -zxvf *.tar.gz
But I get this.
Code:
tar: xmms-256.tar.gz: Not found in archive
tar: xmmearth.tar.gz: Not found in archive
tar: titanium.tar.gz: Not found in archive
tar: sword.tar.gz: Not found in archive
tar: spiffMEDIA.tar.gz: Not found in archive
tar: sinistar.tar.gz: Not found in archive
tar: nuance-green-2.0.tar.gz: Not found in archive
tar: nuance-2.0.tar.gz: Not found in archive
tar: nixamp2.tar.gz: Not found in archive
tar: myway.tar.gz: Not found in archive
tar: minEguE-xmms-v2.tar.gz: Not found in archive
tar: minEguE-xmms-v1.tar.gz: Not found in archive
tar: maXMMS.tar.gz: Not found in archive
tar: m2n.tar.gz: Not found in archive
tar: ions.tar.gz: Not found in archive
tar: gLaNDAmp-2.0.tar.gz: Not found in archive
tar: fyre.tar.gz: Not found in archive
tar: fiRe.tar.gz: Not found in archive
tar: eMac_Xmms_color_schemes.tar.gz: Not found in archive
tar: eMac-XMMS.tar.gz: Not found in archive
tar: detone_green.tar.gz: Not found in archive
tar: detone_blue.tar.gz: Not found in archive
tar: cracked.tar.gz: Not found in archive
tar: cherry_best.tar.gz: Not found in archive
tar: cherry.tar.gz: Not found in archive
tar: chaos_XMMS.tar.gz: Not found in archive
tar: cart0onix.tar.gz: Not found in archive
tar: bmXmms.tar.gz: Not found in archive
tar: blueHeart_Xmms.tar.gz: Not found in archive
tar: blueHeart-xmms-20.tar.gz: Not found in archive
tar: blackstar.tar.gz: Not found in archive
tar: arctic_Xmms.tar.gz: Not found in archive
tar: XawMMS.tar.gz: Not found in archive
tar: XMMS-Green.tar.gz: Not found in archive
tar: XMMS-AfterStep.tar.gz: Not found in archive
tar: X-Tra.tar.gz: Not found in archive
tar: WoodPanel.tar.gz: Not found in archive
tar: Winamp_X_XMMS_1.01.tar.gz: Not found in archive
tar: Vulcan21.tar.gz: Not found in archive
tar: Vulcan.tar.gz: Not found in archive
tar: Vegetal_Blues.tar.gz: Not found in archive
tar: Vegetali_1-1.tar.gz: Not found in archive
tar: UltrafinaSEM.tar.gz: Not found in archive
tar: UltrafinaSE.tar.gz: Not found in archive
tar: Ultrafina2000.tar.gz: Not found in archive
tar: Ultrafina.tar.gz: Not found in archive
tar: Ultrafina-pw.tar.gz: Not found in archive
tar: SuedE.tar.gz: Not found in archive
tar: Plume-XMMS-v1.tar.gz: Not found in archive
tar: Panic.tar.gz: Not found in archive
tar: OmniAMP-1.3.tar.gz: Not found in archive
tar: NoerdAmp-SE.tar.gz: Not found in archive
tar: NeXTAmp2.4.tar.gz: Not found in archive
tar: NeXTAmp2-1.0pre1.tar.gz: Not found in archive
tar: MarbleX.tar.gz: Not found in archive
tar: Marble.tar.gz: Not found in archive
tar: LinuxDotCom.tar.gz: Not found in archive
tar: Inverse.tar.gz: Not found in archive
tar: Helix-Sawfish-xmms.tar.gz: Not found in archive
tar: HeliXMMS.tar.gz: Not found in archive
tar: Ghost-10.tar.gz: Not found in archive
tar: GTK+.tar.gz: Not found in archive
tar: Freshmeat_Amp.tar.gz: Not found in archive
tar: FreeBSD.tar.gz: Not found in archive
tar: FB_2.1.tar.gz: Not found in archive
tar: FB_1.2.tar.gz: Not found in archive
tar: Eclipse.tar.gz: Not found in archive
tar: Cyrus-XMMS.tar.gz: Not found in archive
tar: Covenant.tar.gz: Not found in archive
tar: Coolblue.tar.gz: Not found in archive
tar: Concept_X.tar.gz: Not found in archive
tar: ConceptX-Gold.tar.gz: Not found in archive
tar: ColderXMMS.tar.gz: Not found in archive
tar: Cobalt-Obscura.tar.gz: Not found in archive
tar: CX2.tar.gz: Not found in archive
tar: BrushedMetal_Xmms.tar.gz: Not found in archive
tar: BlueSteel_xmms.tar.gz: Not found in archive
tar: BlueSteel.tar.gz: Not found in archive
tar: BlueIce.tar.gz: Not found in archive
tar: BlackXMMS.tar.gz: Not found in archive
tar: Aqua.tar.gz: Not found in archive
tar: Apple_Platinum_Amp.tar.gz: Not found in archive
tar: AdamAmp.tar.gz: Not found in archive
tar: Absolute_Blue-XMMS.tar.gz: Not found in archive
tar: Error exit delayed from previous errors.
What I am missing?
 
Well I found a solution :)
Create a simple text named sh ,inside the folder with all tar archives.
Write this lines into sh file.
Code:
#/bin/sh
for file in `ls *.tar.gz`
do
tar zxvf $file
done
Save it and Run:
Code:
chmod +x sh
chown -R [B]user[/B] sh
./sh
Where user is the output of command: whoami
Done :)
 
I will say why I prefer script.
If I must do this a lot of times, I write one time the script and I run it always.
Is faster to write the same thing again and again. A can even remember it :p
 
This is even simpler, and also works if the filenames contain special characters:
Code:
for i in *.tar.gz; do tar -xvf "$i"; done

If the sudo is actually needed, consider
Code:
sudo sh -c 'for i in *.tar.gz; do tar -xvf "$i"; done'
instead of placing sudo before tar to avoid needing to type your password several times if the process takes very long.
 
Hey, I'm pretty much trying to achieve the same thing.

Untar multiple archives. However, I am required to untar them in different directories that have the name of the source archive.

For example the archives are:

archive01.gz
archive02.gz
archive03.gz

I will need to untar them as follows:

archive01 <- that's a directory containing all files that were in archive01.gz
archive02
archive03

So far I tried
Code:
for a in `ls -1 *.gz`
do
 #now we're gonna remove all the extension (all that's after the dot) and use that as the folder name
 mkdir `echo ${a%%.*};`;
 tar xzvf $a;
done

However my code doesn't work for some reason.

Any thoughts would be kindly appreciated.

Thanks.
 
i doubt it will work. where do you pass the mkdir parameter ? you don't even tell tar to create such dir. i am working on a variant now.
 
Problem solved:
Code:
for a in `ls -1 *.gz`
do
 #now we're gonna remove the extension (all that's after the dot) and use that as the folder name
 mkdir `echo ${a%%.*};`;
 tar xzv --directory ${a%%.*} --file $a;
done
 
What shell are you using?
If it's csh, try something like this
Code:
foreach t (*.gz)
 d=$t:r
 mkdir $d;
 (cd $d; tar -xzf ../$t)
end

Or similar in sh
Code:
for t in *.gz
do
 d=`echo $t|sed -e 's/.gz//'`
 mkdir $d
 tar -C $d -xzf $t
done
 
Back
Top