Saturday, 14 September 2013

How can I extract a long list of tarballs via STDIN?

How can I extract a long list of tarballs via STDIN?

I'm copying bunch of .tar backups of user home directories to a new server
and have the tarballs already copied from the old server to the new
server.
For Example;
[root@example.com /home]# ls /home |grep tar
returns:
user1.tar
user2.tar
user3.tar
[etc]
But making things a little trickier, the tarballs were created from the
root directory on the original server so a default extraction has 'home'
in the default path e.g.;
[root@example.com /home]# tar -xvf user1.tar
extracts to a new home directory relative to where your running the
command and places the extracted files at the path
/home/home/user1
The closest I believe I have come to what's required (with a few different
variations);
[root@example.com /]# ls /home |grep tar |tar -xvf -
returns;
tar: This does not look like a tar archive
tar: Exiting with failure status due to previous errors
Now I realize there's a lot of workarounds for each of the different
pieces, but if I'm going to grow up to be a super-cool sysadmin like my
friends, I should probably know super-cool tricks like this.
Thanks!

No comments:

Post a Comment