Awk script Problem

Hi ,

I am having two files FILE1 and FILE2 as shown below
I need to search each and every element of Coulumn1 in the FILE1 in FILE2 and Globally replace with the Corresponding element of the Column2 in the FILE2 , For example and1 which is the first element of COl 1 of the FILE1 should be searched in the FILE2 and should be replaced with the man which is a first element of the Column2 , Col1 should be replaced with Col2 in FILE2

 
FILE 1:
 
and1      man
nand2     nase 
nor3      cage
inv4      phase
buff5     daise
or6       matry

FILE2 :

 
NET .(and1) 
PPIN GATE2(and1)
POLYNATION .(A) .(B)=and1
 
NET .(nand2) 
PRIGHT GATE49(nand2)
POLYNATION18 .(A) .(B)=nand2
 
NET .(nor3) 
Pry GATE29(nor3)
POlo009 .(A) .(B)=nor3
 
NET .(inv4) 
PPIN8 GATE2(inv4)
POLYN90 .(A) .(B)=inv4
 
NET .(buff5) 
PPINMAS GATE2(buff5)
POLYNATION90 .(A) .(B)=buff5
 
NET .(or6) 
PPI GATE2(or6)
POLYTRY .(A) .(B)=or6

OUTPUT FILE

 
 NET .(man) 
PPIN GATE2(man)
POLYNATION .(A) .(B)=man
 
NET .(nase) 
PRIGHT GATE49(nase)
POLYNATION18 .(A) .(B)=nanse
 
NET .(cage) 
Pry GATE29(cage)
POlo009 .(A) .(B)=cage
 
NET .(phase) 
PPIN8 GATE2(phase)
POLYN90 .(A) .(B)=phase
 
NET .(daise) 
PPINMAS GATE2(daise)
POLYNATION90 .(A) .(B)=daise
 
NET .(matry) 
PPI GATE2(matry)
POLYTRY .(A) .(B)=matry

I tried to use the VI Editor Record option but Global replacement for one element at two to three instances are not possible it seems
I tried to use the awk but comparing two files and searching element and globally replacing it was bit of taks for me ... new to Awk

Please help me out for this issue

Maybe smthg like

while read a b
do
     sed -i "s/$a/$b/g" File2
done <File1

or

while read a b
do
     echo ",s/$a/$b/g\nw\nq\n" | ed -s File2
done <File1

Or awk:

 awk 'NR==FNR{A[$1]=$2;next}{for(i in A)gsub(i,A)}1' file1 file2

Hi

Thanks Ctsgnb ,

This sed code is not working for me ,
I am getting some errors while running it on the Shell
sed: -e expression #1, char 0: no previous regular expression
sed: -e expression #1, char 0: no previous regular expression
sed: -e expression #1, char 0: no previous regular expression

So many Errors are coming
Can you resend this Sed Code

Thanks
Jaita

# cat f1
and1      man
nand2     nase
nor3      cage
inv4      phase
buff5     daise
or6       matry
# cat f2
NET .(and1)
PPIN GATE2(and1)
POLYNATION .(A) .(B)=and1

NET .(nand2)
PRIGHT GATE49(nand2)
POLYNATION18 .(A) .(B)=nand2

NET .(nor3)
Pry GATE29(nor3)
POlo009 .(A) .(B)=nor3

NET .(inv4)
PPIN8 GATE2(inv4)
POLYN90 .(A) .(B)=inv4

NET .(buff5)
PPINMAS GATE2(buff5)
POLYNATION90 .(A) .(B)=buff5

NET .(or6)
PPI GATE2(or6)
POLYTRY .(A) .(B)=or6
while read a b
do
echo ",s/$a/$b/g\nw\nq\n" | ed -s f2
done <f1
#  cat f2
NET .(man)
PPIN GATE2(man)
POLYNATION .(A) .(B)=man

NET .(nase)
PRIGHT GATE49(nase)
POLYNATION18 .(A) .(B)=nase

NET .(cage)
Pry GATE29(cage)
POlo009 .(A) .(B)=cage

NET .(phase)
PPIN8 GATE2(phase)
POLYN90 .(A) .(B)=phase

NET .(daise)
PPINMAS GATE2(daise)
POLYNATION90 .(A) .(B)=daise

NET .(matry)
PPI GATE2(matry)
POLYTRY .(A) .(B)=matry