Code:
file
1,2,33,C,B
3,5,66,K,R
1,2,33,H,M
3,5,66,M,C
6,9,66,J,F
4,8,55,H,P
5,7,44,N,U
input.txt
66
55
CODE:
awk '{print $1}' input.txt | while read line
do
awk -F, '$5 = $3 == find ? replace : $5 ' OFS=, find=$line replace=77 file >>Output.txt
done<inputfile
Output.txt
1,2,33,H,M --->loop 1
4,8,55,H,P --->loop 1
5,7,44,N,U --->loop 1
1,2,33,C,B --->loop 2
3,5,66,K,R --->loop 2
1,2,33,H,M --->loop 2
3,5,66,M,C --->loop 2
6,9,66,J,F --->loop 2
5,7,44,N,U --->loop 2