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. 

Sent from my iPhone

On Oct 12, 2017, at 10:42, Adam Thompson <athompso@athompso.net> wrote:

On 2017-10-12 08:59, Kevin McGregor wrote:

Given a gzipped cpio archive (12 GB!) with files in it like:
 
wwdsvdccb101/root/data/ccb/ccbx/splapp/servers/myserver/tmp/.appmergegen_1347913274622/SPLWeb.ear/h7y1ba/data/xml/CILICEXP.xml
wwdsvdccb101/root/data/ccb/ccbx/splapp/servers/myserver/tmp/.appmergegen_1347913274622/SPLWeb.ear/h7y1ba/data/xml/CILTSVTP.xml
wwdsvdccb101/root/data/ccb/ccbx/splapp/servers/myserver/tmp/.appmergegen_1347913274622/SPLWeb.ear/h7y1ba/data/xml/C1LOOUPP.xml
wwdsvdccb101/root/data/ccb/ccbx/splapp/servers/myserver/tmp/.appmergegen_1347913274622/SPLWeb.ear/h7y1ba/data/xml/CILTTRAL.xml
wwdsvdccb101/root/data/ccb/ccbx/splapp/servers/myserver/tmp/.appmergegen_1347913274622/SPLWeb.ear/h7y1ba/data/xml/CILCSSPL.xml
wwdsvdccb101/root/data/ccb/ccbx/splapp/servers/myserver/tmp/.appmergegen_1347913274622/SPLWeb.ear/h7y1ba/data/xml/CILTCLGP.xml
 
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.
 
Any ideas?
 
 
 
sed(1)  :-D
 
Seriously, I don't think it's possible.
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.
Best I can suggest is pre-create the directory structure you want, then pre-create a matching tree of symlinks.
 
e.g.:
  # mkdir wwdsvdccb202
  # ln -s wwdsvdccb202 wwdsvdccb101
  # gunzip file | cpio <magical extract flags>
 
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:
  # mkdir /var/data/wwdsvdccb202
  # ln -s /var/data/wwdsvdccb202 /tmp/wwdsvdccb101
  # cd /tmp
  # gunzip file | cpio <magical extract flags>
 
Sorry I can't be of more help :-(
 
-Adam