Web Hosting Talk







View Full Version : Tar Question


bert
04-21-2002, 09:48 PM
Hi,

Can anyone tell me how to untar multiple files at once?

Lets say I have file1.tar.gz, file2.tar.gz and file3.tar.gz inside /backup. How would I untar them all without having to specify them one by one?

I tried using a wildcard such as:
tar -zxpf *.tar.gz but it didn't work.

Thanks!

priyadi
04-21-2002, 10:47 PM
You can't, really, tar can only process one file (or stream) at a time...

If you need to untar more than one file at once, you need to do some scripting. One of the following commands should work:

- for i in *.tar.gz ; do tar zxpf $i ; done
- zcat *.tar.gz | tar xfp -
- ls *.tar.gz | xargs tar zxpf

Substitute *.tar.gz with the exact location of your tar files.

bert
04-21-2002, 10:49 PM
Thanks priyadi, I just realized that. I will write a simple perl script that will do this for me :)