Extract Multiple tar files

Hello,

I would like to extract multiple tar files using one command.

How can I do that?

Mateusz

Posted on Oct 9, 2005 2:58 PM

Reply
13 replies

Oct 12, 2005 8:14 AM in response to Jeff Hubbach

Hi Jeff,

I believe

tar -xvf *.tar

does not work because the shell replaces *.tar by a list of files matching that pattern. The tar 'f' option, however, expects only one filename as parameter.
For instance, if you have f1.tar and f2.tar in that directory, the above command will be translated by the shell to:

tar -xvf f1.tar f2.tar

Which doesn't work, if I am not mistaken...

Just my 2 cents :-D

Antonello

Oct 13, 2005 11:57 AM in response to Jeff Hubbach

I'm so used to passing multiple files to tools on the command-line, I didn't even stop to think that one wouldn't work with multiples.


Same here. I could have sworn I have extracted multiple tar files this way... I was wrong.

A caution on Jeff's find command- If the directory with the tar files has no sub dirs then this is great, but if for example the tar files are at root (/) then this command will search the whole system (including mounts) looking for, then extracting tar files.

Reese

Oct 13, 2005 12:01 PM in response to reese_

A caution on Jeff's find command- If the directory with the tar files has no sub dirs then this is great, but if for example the tar files are at root (/) then this command will search the whole system (including mounts) looking for, then extracting tar files.


Good point. You can add a -maxdepth flag to the find command.

find . -name '*.tar' -maxdepth 1 -exec tar -xvf {} \;


This will extract all tar files that are located in the current directory.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Extract Multiple tar files

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.