For recursively copying a directory, using tar
to pack up a directory and then piping the output to another tar
to unpack seems to be much faster than using cp -r
(or cp -a
).
Why is this? And why can't cp
be made faster by doing it the same way under the hood?
Edit: I noticed this difference when trying to copy a huge directory structure containing tens of thousands of files and folders, deeply nested, but totalling only about 50MB. Not sure if that's relevant.