I have two files I am trying to read line by line, but I only want to continue reading from only file or the other on any given iteration of a loop. (I am also unsure how to check for EOF). Here is my pseudocode:
#initialize variables
line1=read <file1.txt
line2=read <file2.txt
#compare lists
while true
do
#check if there is a match
if [[ "$line1" == "$line2" ]]
then
echo match
break
elif [ "$line1" -lt "$line2" ]
then
line1=read <file1.txt # <-SHOULD READ NEXT LINE OF F1
else
line2=read <file2.txt # <-SHOULD READ NEXT LINE OF F2
fi
#Check for EOF
if [[ "$line1" == EOF || "$line2" == EOF ]]
then
break
fi
done
Obviously, as it stands now, this would continue reading just the first line of F1 and F2. Any help would be greatly appreciated!