automating file search and replace text

Hi, I am trying something like this: Let's say I have a file called File1 with contents:
x=-0.3
y=2.1
z=9.0

I have another file, File2, with contents:

xx=
yy=
zz=

(nothing after "="). What I want to do is get the value of x in File1 and set it to xx in File2, i.e., xx=-0.3. And the same thing for y and z, value of y will be set to yy and z to zz (yy=2.1, zz=9.0).

Now, I want to do this with grep and sed and without using any other
language. Also, I cannot know the numbers in File1. The process should be automatic. Is there a way to do this in the command line itself? Only one step is enough, for example, x in File1 to xx in File2 step. thanks,

Try using awk instead of grep and sed, e.g...

$ head file[12]
==> file1 <==
x=-0.3
y=2.1
z=9.0

==> file2 <==
xx=
yy=
zz=

$ awk 'BEGIN{FS=OFS="="}NR==FNR{a[$1 $1]=$2;next}{print $1,a[$1]}' file1 file2
xx=-0.3
yy=2.1
zz=9.0

Hi,

Another way of doing this would be using grep and cut commands inside a loop.

Regards,
Chella

Ygor,

I am not familiar with awk, when I tried your suggestion, I got this:

x=
y=
z=
xx=
yy=
zz=

What can be the issue?
thanks,