[SlugBug] shell script help

Bill Best bill at commedia.org.uk
Wed Aug 6 20:33:40 BST 2003


hi

please envisage the following two directories:

directory1/aaa
directory1/bbb
directory1/ccc

directory2/xxx
directory2/yyy
directory2/zzz

now I suspect that some files in directory2 duplicate some files in 
directory1 - the same data has been uploaded under a different name 
(don't ask).  for example above, directory2/yyy contains exactly the 
same data as directory1/aaa - they just have different names.

i want to write a bash script to compare each file in directory2 to each 
file in directory1 and, if the files are the same, to delete the file in 
directory2.  if a file in directory2 does not match any file in 
directory1 then no action is taken.

i know that `cmp file1 file2` will compare two files in _any_ format and 
will return a '0' if the same and a '1'  if different.  i don't know 
much about scripts, however, nor how to code a for loop.

any help gratefully received.

bb



More information about the SlugBug mailing list