LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 10-15-2003, 06:21 PM   #1
chup
Member
 
Registered: Aug 2003
Location: South Africa
Distribution: Ubuntu (Feisty)
Posts: 280

Rep: Reputation: 31
Untarring multiple files?


anybody knows how to do this?
plz tell

tar zxf '*tar*' doesnt work for some reason
 
Old 10-15-2003, 06:37 PM   #2
chup
Member
 
Registered: Aug 2003
Location: South Africa
Distribution: Ubuntu (Feisty)
Posts: 280

Original Poster
Rep: Reputation: 31
im sorry for creating the thread, i found a great script that untars every file in a directory. maybe a mod can move this thread to another forum?
Code:
#!/bin/sh
# extract all files of known type
# in the current directory.
# alternatively, files can be named 
# on the command line.
self=`basename ${0}` 
if [ $# -ne 0 ]; 
then files=$* 
else files=`echo *`
fi
for file in ${files}; do
  if [ -f ${file} ]; then
    case ${file} in
    *.tar.gz | *.tgz | *.tar.Z)
      tar -xzf ${file}
      ;;
    *.tar.bz2)
      tar -jxf ${file}
      ;;
    *.bz2)
      bunzip2 ${file}
      ;;
    *.tar)
      tar -xf ${file}
      ;;
    *.gz | *.Z)
      gunzip ${file}
      ;;
    *)
      echo ${self}: Filetype unknown.  Skipping file \`${file}\'.
      ;;
    esac
  fi
done # EOF
 
Old 10-15-2003, 08:11 PM   #3
whansard
Senior Member
 
Registered: Dec 2002
Location: Mosquitoville
Distribution: RH 6.2, Gen2, Knoppix,arch, bodhi, studio, suse, mint
Posts: 3,304

Rep: Reputation: 65
this might give you something to think about

find . -name "*.tgz" -exec tar zxvf {} \;

that goes into subdirectories though.
 
Old 10-16-2003, 02:12 PM   #4
chup
Member
 
Registered: Aug 2003
Location: South Africa
Distribution: Ubuntu (Feisty)
Posts: 280

Original Poster
Rep: Reputation: 31
Quote:
Originally posted by whansard
this might give you something to think about

find . -name "*.tgz" -exec tar zxvf {} \;

that goes into subdirectories though.
how exactly does this work?
find finds all files in this directory and up ending with .tgz, and then executes tar -zxvf.
i think {} stands for the output of the search, but what is \; ?
please help me
 
Old 10-16-2003, 02:45 PM   #5
whansard
Senior Member
 
Registered: Dec 2002
Location: Mosquitoville
Distribution: RH 6.2, Gen2, Knoppix,arch, bodhi, studio, suse, mint
Posts: 3,304

Rep: Reputation: 65
\;
terminates the command.
 
Old 10-16-2003, 03:21 PM   #6
chup
Member
 
Registered: Aug 2003
Location: South Africa
Distribution: Ubuntu (Feisty)
Posts: 280

Original Poster
Rep: Reputation: 31
oh i see.
thx for the explanation, better to memorize than to use a whole script
 
Old 10-16-2003, 05:10 PM   #7
qanopus
Senior Member
 
Registered: Jul 2002
Location: New York
Distribution: Slackware
Posts: 1,358

Rep: Reputation: 45
just do this :

for i in *.tar.gz; do
tar xzf $i; done
 
Old 10-16-2003, 09:01 PM   #8
whansard
Senior Member
 
Registered: Dec 2002
Location: Mosquitoville
Distribution: RH 6.2, Gen2, Knoppix,arch, bodhi, studio, suse, mint
Posts: 3,304

Rep: Reputation: 65
schatoor
Member

Registered: Jul 2002
Location: a tiny place caled hendrik ido ambacht in the netherlands
Distribution: SuSE, debian, slackware, lfs
Posts: 999


your answer doesn't count till you're a guru.
just kidding of course.
 
  


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
untarring archives that span multiple tapes? BrianK Linux - General 2 11-29-2005 09:41 PM
Untarring and installing grilledsalad Linux - Newbie 4 01-01-2005 08:48 PM
Help I need help tarring multiple files in multiple directories VisionZ Linux - Newbie 28 03-25-2004 05:25 PM
Untarring files????? caleb star Linux - Newbie 3 02-03-2004 08:28 AM
untarring, installing contrasutra Linux - Software 6 03-08-2003 12:09 PM

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

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