Beginner here so bear with me. I am trying to compare homework submissions from a solution file and a student submission file. The contents of each file have three problems, one per line:
problem 1 code
problem 2 code
problem 3 code
I want to compare each line in the solution with the corresponding line in the students submission. I am using a for loop to run through each student file and a nested while loop to run through each line of the solution file and student file. For some reason the script is completely ignoring the while loop. I have put echoes between each line to see where the problem is(the echo $solution and echo $submission is just to check to see if the path is correct):
for submission in /home/myfolder/submissions/*
do
echo 1
solution=$(echo /home/myfolder/hwsolution/*)
echo 2
echo $solution
echo $submission
while read sans <&1 && read sol <&2
do
echo 3
echo Student awnser is: $sans
echo Solution is: $sol
echo 4
done 1<$(echo $submission) 2<$(echo $(echo $solution))
echo 5
done
When I run it I get:
1
2
/home/myfolder/hwsolution/solution
/home/myfolder/submissions/student1
5
1
2
/home/myfolder/hwsolution/solution
/home/myfolder/submissions/student2
5
1
2
/home/myfolder/hwsolution/solution
/home/myfolder/submissions/student3
5
1<$(echo $submission)or2<$(echo $(echo $solution))to accomplish. (Also, using file descriptor 1 or file descriptor 2 for input is a really bad idea, as those two are reserved for stdout and stderr, respectively).<"$solution", with noecho.echos inside the loop don't work because you overrode stdout and stderr. (Also, it's not iterating over the lines in the file, but iterating over the names of the files, because of your unnecessary/inappropriateechos in the process substitutions).1<...and2<..., you break any command or program inside the area subject to redirection that tries to log to stdout (FD 1) or stderr (FD 2). And because you broke the logging, you can't see any logs that tell you what you broke.