You are not logged in.

#1 2013-03-06 20:10:51

gyurman
Member
From: Budapest/Hungary
Registered: 2011-03-22
Posts: 65

How can I copy files from tar to another tar

Hello,
I didnt found way, how can I copy file from tar to another tar without write files to disk.
Can you help? I think need pipe, but how?

Offline

#2 2013-03-07 03:22:21

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: How can I copy files from tar to another tar

tar -cf – <source directory> | (cd /<target directory>;tar -xf -)

Moving to Programming and Scripting for better answers...


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#3 2013-03-07 04:41:03

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,217
Website

Re: How can I copy files from tar to another tar

I don't see this as possible. You can extract the file to stdout:

tar xzf --to-stdout source.tar.gz some/file.txt

But to create/append an archive, tar needs to know both the meta data (filename, permissions, owner, group etc) and the content of the file, which can't be passed through a single pipe together.

Last edited by fukawi2 (2013-03-07 04:47:50)

Offline

#4 2013-03-10 12:28:45

deepsoul
Member
From: Earth
Registered: 2012-12-23
Posts: 67
Website

Re: How can I copy files from tar to another tar

gyurman wrote:

how can I copy file from tar to another tar without write files to disk.

Why do you want to do this?  I agree with fukawi2 that it is probably impossible.  Do you want to avoid temporary files for efficiency reasons?  /tmp is a RAM disk these days, so extracting a file there is going to be very fast.


Officer, I had to drive home - I was way too drunk to teleport!

Offline

#5 2013-03-12 05:44:22

gyurman
Member
From: Budapest/Hungary
Registered: 2011-03-22
Posts: 65

Re: How can I copy files from tar to another tar

Hello, thanks. Because I have some of tar from android, and I want mass them. I don't want extract, because of meta tags are changing. What can I do? Thanks

Offline

#6 2013-03-12 12:16:23

deepsoul
Member
From: Earth
Registered: 2012-12-23
Posts: 67
Website

Re: How can I copy files from tar to another tar

So if I understand correctly, you have several tar files from a different system and want to combine them to one big tar file containing all their contents.  Right?

Have you tried the -A / --concatenate option of tar?  I have never used it, but it looks like this is what it's for.

I am not entirely clear on what you mean by "meta tags".  If you mean file system metadata like owner and group, you could use the --same-owner option when extracting (and create a different tar file of everything afterwards).  This will probably require being root.


Officer, I had to drive home - I was way too drunk to teleport!

Offline

#7 2013-03-26 18:05:41

gyurman
Member
From: Budapest/Hungary
Registered: 2011-03-22
Posts: 65

Re: How can I copy files from tar to another tar

Thanks. I probed to concatenate but the size is doubled. Only I could to extract with. sudo tar --same-owner option, this seems to good, and than update the lastest package. But after the updated package owner is changed to root:root if I asked with tar -tvf option.
Im sad, but at now I never mind.

Offline

Board footer

Powered by FluxBB