Need a solution on how to solve this using SED or AWK command in UNIX.
I have a source file whose values have to be populated as following. (Values must be fetched from a reference file and update the source file).
Source file:
aaaa
Uid=xxxx
pwd=nnnn
bbbb
uid=yyyy
pwd=eeee
cccc
uid=zzzz
pwd=kkkk
Reference file:
block, parameter, value
aaaa, uid, 1a1a
aaaa, pwd, 1b1b
bbbb, uid, 2a2a
bbbb, pwd, 2b2b
cccc, uid, 3a3a
cccc, pwd, 3b3b
Output File:
aaaa
Uid=1a1a
pwd=1b1b
bbbb
uid=2a2a
pwd=2b2b
cccc
uid=3a3a
pwd=3b3b
Requirement:
For aaaa, SED must search for Uid within line number 1 and 3 and replace the value which is after the "=". Ie, xxxx with 1a1a.
For bbbb,SED must search for Uid within line number 5 and 7 and replace the value which is after the "=". Ie, yyyy with 2a2a.
Similarly for other parameters.
Thanks.