tar .vs. cpio - (nf)

johnl at haddock.UUCP johnl at haddock.UUCP
Sat Aug 11 13:42:20 AEST 1984


#R:ucbopal:-19800:haddock:16700033:000:1189
haddock!johnl    Aug 10 12:45:00 1984

>Could someone justify the existence of cpio?  What's wrong with tar?

There's nothing wrong with tar, but I like cpio better because it is a
lot more powerful than tar:

  - reading file names from stdin is a feature, not a bug.  You can use
    find to enumerate just the files you want rather than having to dump
    everything in a directory tree, e.g.

	$ find somedir -mtime -14 -print | cpio -oB >/dev/rmt0

    (dump only files modified within the last two weeks.)  Doing this
    with tar is pretty hard.  For the most common cases of cpio, we
    usually have little shell scripts.  Also (hack) the find command has
    a little of cpio built into it so the above example could be:

	$ find somedir -mtime -14 -cpio /dev/rmt0

  - cpio knows about special files and FIFOs.  Most versions of tar
    don't.  Could be fixed, of course.

  - cpio -p lets you copy a directory tree by linking (so that you
    have new names but the same files.)  Tar can't do that.

Basically, anything you can do with tar, you can do with cpio but not the
converse.

John Levine, ima!johnl

PS:  I offer no defense of the internal coding style of cpio, which
still has innumerable MERT-isms.  Ugh.



More information about the Comp.unix mailing list