Edgar Cole
asked on
Copying a Directory on a UNIX System
I've always preferred using the tar command instead of the cp command to copy the content of a directory on a UNIX system. That's because I found that using the cp command was unpredictable and unreliable. I know there are those who are fond of cpio. Anyway, I was just wondering whether my misgivings about the cp command are justified.
ASKER
Hmm. I'm wondering whether tar is faster than cp.
No, tar isn't any faster - from a system standpoint, they're doing virtually the identical thing.
>> unpredictable and unreliable
How is it unpredictable?
How is it unreliable?
Curious - are you using NFS?
For performance considerations, if the cp is over a network and if you have 1000's of files being copied, then transmitting a tar archive, a single file, incurs less overhead than transmitting many files.
How is it unpredictable?
How is it unreliable?
Curious - are you using NFS?
For performance considerations, if the cp is over a network and if you have 1000's of files being copied, then transmitting a tar archive, a single file, incurs less overhead than transmitting many files.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
So for jobs that I do repetitively, I prefer:
(cd /source/directory && tar cpf - dir1 dir2 dirX ) | (cd /dest/directory && tar xvfp -)
over:
cp -Rv /source/directory /dest/directory
But to answer your question, misgivings are much the same as preferences which means you don't have to "justify" them per se - you should use what gets the job done and poses the least stress or risk to you.