[plug] tar vs cp -r

Denis Brown dsbrown at cyllene.uwa.edu.au
Thu Mar 10 15:45:58 WST 2005


At 02:51 PM 10/03/2005, Jim Householder wrote:
>Hi
>
>On a number of occasions I have seen a preference shown for using tar to 
>move large trees rather than cp -r.
>
>What is the advantage of tar?  Properties and links handling perhaps?

As I understand it the advantage of the tar construction is one of speed... 
you need two "tar's" of course, one to create the archive and another to 
extract it.   The queueing is such that it is more efficient because the 
reads and writes queue simultaneously.   cp on the other hand uses 
sequential reads and writes.

Tar also handles symlinks, etc out-of-the-box whereas cp depends on -r (or 
-R rather) to handle these cases.   From one of my Gentoo installations' 
"man cp" pages...

<quote>
       -R     Copy  directories  recursively,  and  do  the  right  thing when
               objects other than ordinary files  or  directories  are  encoun-
               tered.   (Thus,  the copy of a FIFO or special file is a FIFO or
               special file.)

        -r     Copy directories recursively, and do something unspecified  with
               objects  other than ordinary files or directories.  (Thus, it is
               allowed, in fact encouraged, to have the -r option a synonym for
               -R.  However,  silly behaviour, like that of the GNU 4.0 version
               of cp is not forbidden.)
</quote>

HTH,
Denis







More information about the plug mailing list