How to extract the attached tar.gz files easily?

I need to extract a tar.gz file. That's about 950 MB. It has 23 more tar.gz files. Each of these 23 tar.gz files has one tar file. My questions are, how can I easily extract all of them? Is there a command line tool that I can use?

The structure looks like this:

foo.tar.gz
 β”œβ”€β”€β”€bar1.tar.gz
 β”‚   β”œβ”€β”€β”€foobar1.tar
 β”œβ”€β”€β”€bar2.tar.gz
 β”‚   β”œβ”€β”€β”€foobar2.tar
 β”œβ”€β”€β”€bar3.tar.gz
 β”‚   β”œβ”€β”€β”€foobar3.tar
 β”œβ”€β”€β”€bar4.tar.gz
 β”‚   β”œβ”€β”€β”€foobar4.tar
 β”œβ”€β”€β”€bar5.tar.gz
 β”‚   β”œβ”€β”€β”€foobar5.tar
 β”œβ”€β”€β”€bar6.tar.gz
 β”‚   β”œβ”€β”€β”€foobar6.tar
 |   ..........
 |   ..........
 |   ..........
 |   23 of them

      

Thanks in advance.

+2


a source to share


3 answers


As a result, I manually extracted foo.tar.gz and used the following shell script to extract those * .tar.gz files.

#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
for next in *.tar.gz
    do
        echo "Untaring - $next"
        tar -xzf $next -C ~/foo
    done
exit 0

      



hope this helps someone.

+1


a source


You can use an argument --to-command

to pass each extracted file to another program (to stdin). In this case, you are passing it to another tar instance data file from stdin.



tar --to-command='tar -xzvf -' -xzvf foo.tar.gz

      

+2


a source


Yes.

tar -xzOf foo.tar.gz bar1.tar.gz | tar -xO foobar1.tar

      

Must do the trick.

0


a source







All Articles