Suppose i have two files
file1.txt
Name : Raju
Address:rt8pouououoiu
City:tyretyeuetu
file2.txt
Address :28a
The line "address:28a" in file2 has to get replaced in the address line of file1 ..
The output should be
Name :Raju
Address:28a
city :tyretyeuetu
Please help me on this
sb008
2
I'm sure the real (n)awk experts have a better solution.
nawk '/^Name[ ] { NAM=$0 }; /^Address[ ] { ADDR=$0 }; /^City[ ]* { print NAM"|"ADDR"|"$0 }' file1.txt | paste -d"|" - file2.txt | nawk '{ FS="|" } { print $1; print $4; print $3 }'
Ygor
3
Try...
awk '/Address:/{getline < "file2.txt"}{print}' file1.txt