I have 2 files file1.csv and file2.csv
file1.csv contains only 1 column with hundreds of rows.
aaa
ddd
fff
ggg
file2.csv contains 5 fields with thousands of rows.
aaa,2,3,4,
aaa,2,3,4,
bbb,2,3,4,
ccc,2,3,4,
ccc,2,3,4,
ddd,2,3,4,
ddd,2,3,4,
ddd,2,3,4,
eee,2,3,4,
fff,2,3,4,
ggg,2,3,4,
hhh,2,3,4,
hhh,2,3,4,
My task is to check if col1 present in file1.csv matches with col1 in fil2.csv then change the 5th column to Y in file2.csv
Desired output
aaa,2,3,4,Y
aaa,2,3,4,Y
bbb,2,3,4,
ccc,2,3,4,
ccc,2,3,4,
ddd,2,3,4,Y
ddd,2,3,4,Y
ddd,2,3,4,Y
eee,2,3,4,
fff,2,3,4,Y
ggg,2,3,4,Y
hhh,2,3,4,
hhh,2,3,4,
what i tried is
for i in $(cat file1.csv); do awk -F "," '$1==$i{$5="Y"}1' OFS="," file2.csv ; done
But I am getting only the matched records but not the unmatched records.
Is there a better way I can achieve this in UNIX using awk,sed or other common utility.
EDIT: Update question with clear example