9
2
edit: I want to extra member01
and member02
and directory blah/
tarball_1.tar.gz
contains directory test/
with 20 files. I want to extract only member test/member01
and test/member02
and directory blah/
and copy them to another "remote_host" using ssh/scp.
Can this be done as a one-liner?
I considered using tar
, pax
, or cpio
but I guess I'm not very skilled with these utilities yet.
2Alternatively, if "one-liner" is more important than "how long it takes", you can pipe the whole archive through ssh and extract the members you want on the other side "cat file.tar.gz | ssh user@host 'tar zxvf file1 file2 dir1' – Colin – 2015-04-15T03:29:55.450
I was not clear in my original posting :) I need to extract more than one member, plus a directory. – Felipe Alvarez – 2011-08-30T08:55:41.880
should be tar -xz0f : after
f
comes archive name – Felipe Alvarez – 2011-08-30T08:56:56.4801Extracting multiple members will get messy if you want them to be one-liners, since extracting multiple files to stdout doesn't quite make sense. You'll probably have to
tar
for each one you want to extract, then usescp -r member1 member2 blah user@host:/destination/folder/
to copy them. If you really want to make it one-line, you can concatenate all those commands with&&
. A more practical option is to just make a script as well that iterates through the command-line options and executestar
for each one and thenscp
s all of them at the end. – atanamir – 2011-08-30T09:18:12.087ahhhhh, I see. So there is no "easy" one-liner method. Thanks :-) – Felipe Alvarez – 2011-08-30T09:27:09.207