File comparision

HI,

I would like to know how to compare two files and replace non-matching lines with "_" .

I can get non-mathing lines with
grep -v -f file1 file2

i just want to knw how to display 'file2' with non-matching lines from 'file1' replaced by "_"

for exmaple

file1:
a
b
c
d

file2:

m
c
n

required output is :

_
_
c
_

Thanks in advance

Homework?

while read VAR; do grep $VAR file2 || echo _; done < file1

Thank u. This is exactly what I needed now.