Replacing string values from a File

I want to replace string values from a file to a file

For eg : File1 has 30 lines of string with values, those specific values needs to be changed in file2 and remaining values in file2 should be as it is.

For example:

From file (File1)
cluster.name=secondaryCluster

To replace File (File2)
cluster.name=CoreSetupCluster

(in the above CoreSetupCluster in file2 should be changed to secondaryCluster as in file1

awk 'BEGIN{FS=OFS="="}NR==FNR{a[NR]=$NF;next}{$NF=a[FNR]?a[FNR]:$NF}1' file1 file2

Value not changed :

sriram@ubuntu:~/perl/Awk$ awk 'BEGIN{FS=OFS="="}NR==FNR{a[NR]=$NF;next}{$NF=a[FNR]?a[FNR]:$NF}1' file1 file2
value=value1
value2=value3

sriram@ubuntu:~/perl/Awk$ cat file1 
value=value1
value2=value3

sriram@ubuntu:~/perl/Awk$ cat file2
value=value1
value2=value2
awk -F= 'NR==FNR{a[$1]=$2;next}a[$1]{$2=a[$1]}1' OFS="=" file1 file2 > newfile

No , :frowning: ,, Let me be more clear and explain you... file1 contains 10 entries , all entries are seperated with = sign, file2 contains 100 entries... all i want is if any lines starting before = sign matches file1 in file2 , then replace that particular line in file2 with file1 values ... hope i am more clear this time...

Thanks,

The question was quite clear. What doesn't work? What output did you get?

yes looks good ... how do i replace it in actual file rather than a new file >> does not work

Replace file2 with newfile:

awk -F= 'NR==FNR{a[$1]=$2;next}a[$1]{$2=a[$1]}1' OFS="=" file1 file2 > newfile
mv newfile file2

that will completely rename ... I only want to replace lines which is found ... the other lines in the file will be as it is.

Did you check the difference between file2 and newfile?