Help on untar files in one command

Hi All,

I need your help to find out an easy way to untar files from a tar file.

For example, I have a tar file which contains a lot of files that needs to untar in certain directories. I would like to untar them using one command instead of typing the following commands which is taking lots of time. Is there an easy way to do that?

tar -xvf ABC.tar bin/file1
tar -xvf ABC.tar bin/name
tar -xvf ABC.tar bin/address
tar -xvf ABC.tar bin/status
tar -xvf ABC.tar bin/city
tar -xvf ABC.tar bin/country
����������� 
����������� 



tar -xvf ABC.tar lib/file7
tar -xvf ABC.tar lib/post
tar -xvf ABC.tar lib/get

[/FONT]

How many files?

tar -xvf ABC.tar bin/file1 bin/name bin/address bin/status bin/city bin/country lib/file7 lib/post lib/get

Thanks for your quick response. I have about 35 files in bin and 74 files in lib to untar. I think I can put them in a input file then run it as following...

for i in `ls tar_list`
do
tar -xvf ABC.tar $i
done
 

any other easy thoughts?

Not sure what "tar_list" is. A file containing a list of the files to untar, I presume, so that should probably be "cat tar_list"?

No need for the cat, anyway:

while read i; do
  tar -xvf ABC.tar "$i"
done < cat_list

yes tar_list contains all the untar file lists. sorry, I actually meant

 
for i in `cat tar_list`
do
tar -xvf ABC.tar $i
done

thank you for your help

As I said, there's no need for "cat".

A shorter alternative:

xargs < tar_list -I{} tar xf ABC.tar {}

(you can add the xargs -n option if there's too many files)

That's a useless use of backticks and useless use of cat and almost always better done as

while read LINE
do
...
done < filename

As for how to feed all those filenames into tar, if none of the files contain spaces or quotes in filenames, it's easy enough, use xargs. "echo a b c | xargs command" amounts to "command a b c", and it can read from a file.

xargs tar -xvf filename.tar < tar_list

If possible it will squeeze it alll into one tar call, but for too many files, it may have to break it into a few.