Grep and replace multiple strings in a file with multiple filenames in a file

Hi,

I have a file containing list of strings like

i:
Pink
Yellow
Green

and I have file having list of file names in a directory

j :
a
b
c
d

Where j contains of a ,b,c,d are as follows
a:
Pink
White

b
Yellow
Pink

c
Pink
Yellow
Green

d
Red
white

My intention is to check all the strings in i for all the file names in j and if that strings are present in any of listed files in j those strings should be modified as new_<string> instead of <string> in original files

o/p :

a:
new_Pink
White

b
new_Yellow
new_Pink

c
new_Pink
new_Yellow
new_Green

d
Red
white

Thanks

Please use code tags for posting code fragments or data samples!

Show us what you have tried so far.

Use sed to make lines of file i into a sed script lines: s/color/new_color/. Call that script with all files in j, using sed -i.

Please use code tags as required by forum rules!

Try this and rename new_filenames to original filenames afterwards:

awk     'NR==FNR        {R[$1]; next}
         $1 in R        {$1="new_"$1}
                        {print >"new_"FILENAME}
        ' i $(cat j)