I have a tar file that contains some files in a folder named old_name
. Now I'd like to create a new tar file where that folder has been renamed to new_name
without extracting to file to disk as that would be significantly slower for large archives (More than double the disk reads and writes).
I know how to do that: tar -xf old.tar; tar -cf new.tar --transform 's/old_name/new_name/' old_name
I've tried a few things but none seemed to work:
tar -cOf old.tar | tar -xf new.tar --transform 's/old_name/new_name/'
cat old.tar | tar --delete --transform 's/old_name/new_name/' > new.tar
cat old.tar | tar -u --transform 's/old_name/new_name/' > new.tar
But nothing seems to work.
Closed I've found are these:
But those are about removing files in the tarball, not changing their paths.
/dev/shm
), so that it is in RAM, not on disk. – Quasímodo Jul 01 '20 at 11:19--transform s/foo/bar/
, it won't modify your archive file a you wanted. i mention for t anyone who may find it a suitable work around to only apply this rename/fix at extract time – ThorSummoner Jul 07 '20 at 18:21