Replace Content

Hello all ; )

I'got a file1 with a lot of emails like :

fistname.lastname@domaine1.com

And another file2 with emails like

fistname.lastname@domaine2.ct.net

I need a shell script that will read each line from the file1 and try to find if in file2 the

fistname.lastname

exist.

If yes, the script will have to replace on the file1 the

@domaine1.com

by

@domaine2.ct.net

If not do nothing.

Thanks a lot for your help

ex :
File1

az.et@qsdf.com
sdf.zet@qsdf.com

File2

az.et@wxc.cc.net

at the end of the script only the first line on file1 will be updated :

New file1 will look like this :

az.et@wxc.cc.net
sdf.zet@qsdf.com

Becarefull the script sould not be case sensitive as some adresses may be on lower or upper case.

Hi try:

awk '{i=tolower($1)} NR==FNR{A=$2; next} i in A{$2=A}1' FS=@ OFS=@ file2 file1