Streamable archive formats
Archive formats such as tar(5) and cpio(5) have the advantage of being streamable, so you can use them for transferring data with pipes and remote shells, without having to store the archive in the middle of the process, for instance:
$ cd public_html/blog $ rgrep -lF "archive" data/articles \ | pax -w \ | ssh newserver "mkdir public_html/blog ; cd public_html/blog ; pax -r"
Turning a ZIP archive into tarball
Unfortunately, many people will send you data in non-streamable archive formats such as ZIP¹. For such cases, bsdtar(1) can be useful, as it is able to convert an archive from one format to another:
$ bsdtar -cf - @archive.zip \ | COMMAND
These arguments tell bsdtar to:
- create an archive;
- write it to stdout (contrary to GNU tar which defaults to stdout, bsdtar defaults to a tape device);
- put into it the files it will find in the archive archive.zip.
The result is a tape archive, which is easier to manipulate in a stream than a ZIP archive.
Notes
- Some will say that although ZIP is based on an file index, it can be stream because that index is placed at the end of the archive. In fact, that characteristic only allows to stream the archive creation, but requires to store the full archive before being able to extract it. ↑.
11 comments
tuesday 09 december 2014 à 16:48 mirabilos said : #1
tuesday 09 december 2014 à 17:20 Tanguy said : #2
sunday 14 december 2014 à 13:09 pini said : #3
monday 15 december 2014 à 11:01 Tanguy said : #4
tuesday 16 december 2014 à 23:11 pini said : #5
thursday 12 may 2016 à 14:58 Romiras said : #6
thursday 12 may 2016 à 15:15 Tanguy said : #7
thursday 12 may 2016 à 15:22 Romiras said : #8
thursday 12 may 2016 à 16:01 Romiras said : #9
thursday 12 may 2016 à 16:02 Tanguy said : #10
thursday 12 may 2016 à 16:07 Romiras said : #11