Re: copying files
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Tuesday 05 November 2002 12:26 am, Richard Kimber wrote:
> Is there a program that will copy files from one directory to another, but
> which will avoid overwriting files with the same name by automatically
> creating a unique filename in the second directory, or is this
> something I need to program for myself?
>
I am making this up as I go along = so its just some random thoughts
assuming two directories like this /base/dir1 and /base/dir2
what about something like this (its not completely correct - it doesn't sort
out files which already have hard links)
cp -al /base/dir2 /base2
cp -alf /base/dir1/* /base/dir2
find /base2/dir2 -depth -type ! d -links 2 -exec rm {} \;
[cp -al makes a copy with hard links, cp -alf merges the two directories and
where its overwritten a file, the base2 file is left with only one link. The
find goes through the base2 directory and removes any files with more than
one link so that what you are left with there is a list of files that were
overwritten]
- --
Alan Chandler
alan@chandlerfamily.org.uk
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
iD8DBQE9xxbRuFHxcV2FFoIRAr5rAJ4kV3eKdiueYCO7ydq92TUeo/mARwCdEPrL
rUPXcc7FdKrOYIvF8OiovlA=
=BuxP
-----END PGP SIGNATURE-----
Reply to: