The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 03-04-2008
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,771
This finds duplicates
Code:
find_dup()
{
awk ' FILENAME=="file1" { arr[$0]++ }
        FILENAME=="file2" { if (arr[$0] { print "value is", $0} }
      ' file1 file2
}
Write a loop that generates one set of filenames - the file1.abc things put it into a file -dirfile1
get another list of the other type of files - call the file dirfile2

Okay now call the find_dup() fuunction for each file combination:
Code:
#/bin/ksh
while read file2 
do
   while read file1 
   do
        ln -s file1 $file1
        ln -s file2 $file2
        result=$( find_dup )
        if [[ ! -z $result ]] ; then
           echo "duplicate found in $file1 and $file2 $result"
        fi
   done  < dirfile1
done < dirfile2  > result.log
result.log will have what you found.