I am trying to replace a section of a file between the first instances of the strings {}, with the contents of another file.
Example of the format of the file I'm trying to modify
Code:
Servername=something.com
hosts {
macaddress1
macaddress2
macaddress3
macaddress4
macaddress5
macaddress6
}
other stuff that
doesn't matter { }
So I would like to replace
Code:
hosts {
macaddress1
macaddress2
macaddress3
macaddress4
macaddress5
macaddress6
}
With data from another file that contains,
Code:
macaddress7
macaddress8
macaddress9
macaddress10
macaddress11
macaddress12
Tried to set,
IFS=""
Then captured all the "macaddress#"s to a variable and used sed to swap
sed "s/$CURRENTDATA/$NEWDATA/" filename
However I get 1 of 2 errors,
Using a small number of macs in "$NEWDATA"
sed: command garbled: s/ macaddresshere
Or when using a large number of macs in the $NEWDATA variable get
bash: /usr/bin/sed: Arg list too long.
Any other ideas on how to replace a large block of txt in one file with another large block from another?
Thanks