By the way, the shortest valid tar command is:
Which reads a tarball from standard input. And unpacks is to the current working directory.
Correct on the shortest valid command. Incorrect on what it does. With traditional
tar, this will try to extract from the tape device
. With GNU tar, it will read from $TAPE, or if that's undefined
, from standard input. Which may be a violation of the POSIX standards, but not one anyone in the world is likely to object to. Still, if you want your script to be portable, use "tar xf -" to extract from standard input if that's what you really want.
Klear wrote:I think winrar (and quite possibly almost every other modern compression software) has the option of creating "solid archive" which is exactly this.
Rar is simply a semi-proprietary variation of tar--or, more precisely, tar and rar are both derivatives of ar. (Nor is rar particularly "modern".)
In addition to the other problems with zip that EvanED mentioned, there's also the fact that it stores the "central directory" at the end of the file, which means it is all-but useless for streaming applications. Tar runs at the end of a pipeline, or even a socket, which makes it extremely flexible. That's why you can do things like "tar czf - foo | ssh user@remote tar xf -". Only the stream going across the pipe gets compressed, so there's no intermediate storage requirements on either end. You can back up a huge drive that way without having enough space on either end
to store the compressed version. Try that
with zip. (Even if there were sufficient free space on both ends, the tar version of transmittal is hugely
faster, because the whole thing is streaming, and thus packing, compression, decompression and unpacking are all happening in parallel.)
Frankly, if I were forced to choose only one archive tool to keep around for the rest of my life, it would definitely be tar--though I have no objections if people use nice front ends (just as winrar is a nice front end to the crufty old rar format).
"[T]he author has followed the usual practice of contemporary books on graph theory, namely to use words that are similar but not identical to the terms used in other books on graph theory."
-- Donald Knuth, The Art of Computer Programming, Vol I, 3rd ed.