How to extract concatenated cpio archive

cpio

% find a/ | cpio -o | gzip -c > alpha.gz
% find b/ | cpio -o | gzip -c > bravo.gz
% cat alpha.gz beta.gz > charlie.gz
% gunzip charlie.gz

Now I get file charlie, which should be a concatenated cpio archive. But cpio -id < charlie only extract the content of a/. How could I get b/?

Added: The size of charlie equals alpha plus bravo. And egrep some key words showed that charlie sure contains data of bravo.

Best Answer

  • The 'alpha' and 'bravo' archives independently contain end-of-archive markers that tell cpio that it's done. This is useful when reading from a tape, because the archive will end but the tape may continue.

    So just like reading from a tape, you need to start another cpio run from the same position; speaking generally, because you know that you have only cpio archives but perhaps aren't entirely sure how many: (while cpio -id ; do :; done) < charlie will happily keep running until cpio errors out ("premature end of archive" when eof is reached).