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
for i ...loop and print the value ofi. Does it contain what you expect? If not, then figure out why. If so, then slowly start adding the next piece, testing as you go. Trying to debug the entire script all at once is much more difficult.whiles: Is this really what you want to do, compare each line of the first file with all lines of the other file? If you rather want to compare each line with the corresponding line of the other file, you need only onewhilewith tworeads.