Similar to my old question: How do I merge FileA.txt and FileB.txt giving FileB.txt overwrite power using a bash script?
I want to merge two configuration value files, again I have fileA and fileB. I want all the lines from fileB in fileA, if the same configuration key appears in both files, I want the value in fileB to overwrite the value in fileA.
Each line always starts with 'config', then there is a key and lastly a value. The part that makes it hard is that the value can be a quoted string with space bars to separate multiple values (see 'website' value).
I've got some experience using awk and a fair bit of bash experience but I can't for the life of me figure out a way to do this. All help is appreciated. Thanks
fileA:
config lanIP 10.1.1.1
config wanIP 1.1.1.1
config wanIPMask 255.255.255.255
config website "http://google.com http://yahoo.com"
fileB:
config lanIP 192.168.1.1
config wanIP 1.1.1.1
config website "http://google.com http://yahoo.com"
config moreWebsite "http://google.com http://msn.com"
Expected output:
config lanIP 192.168.1.1
config wanIP 1.1.1.1
config wanIPMask 255.255.255.255
config website "http://google.com http://yahoo.com"
config moreWebsite "http://google.com http://msn.com"