Comparing Two Binary Folders

I am a beginner to all of this but undertand the basic principles. I am currently working on a large task and struggling with a the final part.

I have two files,

folder 1 contains a list of around 20 files in binary (possibly treated as arrays?)

folder 2 contains several files and sub folders each entry also in binary

all i want to do is basically take each entry of folder 1 and see if there are any matching results in file 2, if there is any matches they should then be moved to a text folder 3

any solutions?

Hi,

Comparing two files you can use below one..

this might help you..

awk 'FNR==NR {a[$0]++; next} a[$0]' file1 file2

Thanks
Va2206

Are you talking about files or folders?? However you can compare files and/or folders using diff.
Another possibility could be list files in folder 1 and check if they exists in folder 2. Then, use diff to compare. Something like:

LIST=files.txt
ls folder1 > $LIST #list files from folder1
cat $LIST| while read line; do #for each filename
   INPUT=$(echo ${line})
   cd $folder2
   if [ -f $INPUT ]; then #check if file exists and its a regular file
      #files exists
      diff $folder1/$INPUT $folder2/$INPUT > dev/nul 2>&1 #compares both
      if [ "$?" == "0" ]; then #check for result.
         #files exists and they're identical
      fi
   fi
done

I'm not sure if you searching for something like this. If so, check it, because it can contain some error: I'm also a newbie :wink:

Albert.