Q:

Replace in place a string in file with text from 2nd file

I have two files as follows
config:
which [box-address]
  Command ssh user[box2-address] 

address:
192.168.0.10

I want to replace in place the [box-address] in "config" with the contents from "address"
I am able to insert the content but overwrite the entire config file each time so instead of 
which 192.168.0.10
  Command ssh user 192.168.0.20

I end up with 
192.168.0.10

as the only thing in the file
What am I doing wrong
awk '/\[box-address\]/{system("cat config");next}1' address > config

A:

You're providing address, not config, as the input to awk. It will never match /\[box-address\]/. Your command is effectively just overwriting config with the content of address.
The following approach should meet your requirements, it reads the content of address into a variable in the BEGIN block and then replaces any instances of [box-address] with it:
awk 'BEGIN{getline l < "address"}/\[box-address\]/{gsub(/\[box-address\]/,l)}1' config

Result:
which 192.168.0.10
  Command ssh user[box2-address]

