cp

Copy files and directories recursively with tar

Copying a directory tree and its contents to another filesystem using


cp -pR directory /newplace

doesn't always do the job.

Using tar instead will preserve ownership, permissions, and timestamps. This neat trick allows using tar to perform a recursive copy without creating an intermediate tar file and overcoming all cp shortcomings.

To copy all of the files and subdirectories in the current working directory to the directory /target, use:


tar cf - * | ( cd /target; tar xfp -)

Syndicate content