Skip to main content
Fr
Source Link
AdminBee
  • 23.6k
  • 25
  • 55
  • 77

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/*CompareScript.txt)
j=0
for i in "$results"
do
   while read -r $results[$j]; do
   sh: line while11: 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
 : `../Results/result1.txt[@]': letnot "ja +=valid 1"
doneidentifier

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

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

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
edited title
Link

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

Source Link

Comparing Two arrays of text files

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