Using cp to copy only new files

Leslie Mikesell les at chinet.chi.il.us
Fri Jun 7 01:45:53 AEST 1991


In article <2620002 at hpcc01.HP.COM> lthompso at hpcc01.HP.COM (Larry L. Thompson) writes:
>>I would like to run a simple shell program to archive data files from
>>my hard disk to an optical disk.  I would like for the archived files
>>to be directly usable from the archive (i.e. tar is no good).  Hence,
>>what I would like is some way to use the cp command with a qualifier
>>that says don't re-copy files that already exist - only new ones.

>OK this is a two step process. You first need to touch a file somewhere
>that will be used as the reference data for filtering files that are newer
>than itself. 
>find . -newer <filename> -hidden -print | cpio -pudmvx <destination>

Actually, cpio will already do exactly what is desired if you leave
out the -u option.

find . -print |cpio -pudmv dest_dir
 will copy all files except those that are newer or the same age on
the destination directory or where there are restrictive permissions.

Les Mikesell
  les at chinet.chi.il.us



More information about the Comp.unix.wizards mailing list