Skip to main content
3 of 3
Fr
AdminBee
  • 23.6k
  • 25
  • 55
  • 77

How to compare two arrays of text files in bash script?

I am trying to compare two arrays of text files. I keep getting this error

./CompareScript.sh: line 11: read: `../Results/result1.txt[@]': not a valid identifier

Not sure how to properly do this

#!/bin/bash
results=(../Results/*.txt)
correct=(../Correct/*.txt)
j=0
for i in "$results"
do
   while read -r $results[$j]; do
     while read  -r $correct[$j];do
        if [$results[$j]==$correct[$j]] ;  then
          echo "two files are same"
        else
          echo "two files content different"
        fi
     done
   done
   let "j += 1"
done