In addition to the @Lekensteyn answer, I'd like to add that this behavior is based on Do one thing and do it well philosophy - tar
program knows how to put multiple files into a single stream (with .tar
extension), gzip
knows how to compress a single file (adding .gz
extension)*. By combining those tools you can create a command which compresses multiple files into a single .tag.gz
file.
This approach is very flexible - you can combine a few standard Unix commands to do all sorts of things. For example, if you write a better program to compress files you don't need to modify tar
to enable it to create .tar.mymegazip
files - instead, you just pipe tar
's output to your compressor.
Similarly, tar
knows nothing about SSH, but by combining commands you can create a script which archives files, uploads them to a remote machine via SSH and un-archives them there.
Compare this to zip
command, which did not originate in Unix - it has built-in tools to compress whole directories, encrypt files, split the archive into smaller zipfiles etc.
(footnote) - yes, tar
is able to gzip or bzip files itself using -z
and -j
switches, they were added for convenience, and GNU tar is actually spawning gzip
or bzip2
as a new process.