<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>Is there a way to untar a tar archive to stdout and use that output to recreate the archive by piping it back into tar? GNU tar has a transform option to change the file names. <br><br>Sent from my iPhone</div><div><br>On Oct 12, 2017, at 10:42, Adam Thompson <<a href="mailto:athompso@athompso.net">athompso@athompso.net</a>> wrote:<br><br></div><blockquote type="cite"><div><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<p>On 2017-10-12 08:59, Kevin McGregor wrote:</p>
<blockquote type="cite" style="padding: 0 0.4em; border-left: #1010ff 2px solid; margin: 0"><!-- html ignored --><!-- head ignored --><!-- meta ignored -->
<div dir="ltr">Given a gzipped cpio archive (12 GB!) with files in it like:
<div>
<div> </div>
<div>wwdsvdccb101/root/data/ccb/ccbx/splapp/servers/myserver/tmp/.appmergegen_1347913274622/SPLWeb.ear/h7y1ba/data/xml/CILICEXP.xml</div>
<div>wwdsvdccb101/root/data/ccb/ccbx/splapp/servers/myserver/tmp/.appmergegen_1347913274622/SPLWeb.ear/h7y1ba/data/xml/CILTSVTP.xml</div>
<div>wwdsvdccb101/root/data/ccb/ccbx/splapp/servers/myserver/tmp/.appmergegen_1347913274622/SPLWeb.ear/h7y1ba/data/xml/C1LOOUPP.xml</div>
<div>wwdsvdccb101/root/data/ccb/ccbx/splapp/servers/myserver/tmp/.appmergegen_1347913274622/SPLWeb.ear/h7y1ba/data/xml/CILTTRAL.xml</div>
<div>wwdsvdccb101/root/data/ccb/ccbx/splapp/servers/myserver/tmp/.appmergegen_1347913274622/SPLWeb.ear/h7y1ba/data/xml/CILCSSPL.xml</div>
<div>wwdsvdccb101/root/data/ccb/ccbx/splapp/servers/myserver/tmp/.appmergegen_1347913274622/SPLWeb.ear/h7y1ba/data/xml/CILTCLGP.xml</div>
</div>
<div> </div>
<div>How can I change the first component of the path to something else without unpacking the entire archive to disk first? Obviously I'll still have to un-gzip and de-cpio the whole 12GB while processing; I just don't want to put the whole thing on disk while I'm changing the path.</div>
<div> </div>
<div>Any ideas?</div>
<div> </div>
</div>
</blockquote>
<div> </div>
<div> </div>
<div>sed(1)  :-D</div>
<div> </div>
<div>Seriously, I don't think it's possible.</div>
<div>Almost all cpio(1)s support the "-r" flag for interactive renaming of files, but that doesn't sound like it would be fun for you.</div>
<div>Best I can suggest is pre-create the directory structure you want, then pre-create a matching tree of symlinks.</div>
<div> </div>
<div>e.g.:</div>
<div>  # mkdir wwdsvdccb202</div>
<div>  # ln -s <span>wwdsvdccb202 wwdsvdccb101</span></div>
<div>
<div><span>  # gunzip file | cpio <magical extract flags></span></div>
<div> </div>
</div>
<div><span>then cpio(1) will extract the files under wwdsvdccb202, thinking it's really under wwdsvdccb101.  If you can't do that in the current directory, then just fake it:</span></div>
<div><span>  # mkdir /var/data/wwdsvdccb202</span></div>
<div><span></span><span>  # ln -s /var/data/wwdsvdccb202 /tmp/wwdsvdccb101</span></div>
<div>
<div><span>  # cd /tmp</span></div>
<span>  # gunzip file | cpio <magical extract flags></span></div>
<div> </div>
<div><span>Sorry I can't be of more help :-(</span></div>
<div> </div>
<div><span>-Adam</span></div>

</div></blockquote></body></html>