Regular expression for matching an IP address.
sed ‘s/\([0-9]\{1,3\}\.\)\{3\}[0-9]\{1,3\}/&HelloWorld/gp’ infile > outfile
will append the string HelloWorld directly after an ipaddress in a file containing ipaddresses e.g.
10.200.200.10 blah
with
10.200.200.10HelloWorld blah
This can be adjusted to replace ip addresses with a string or used to inject some whitespace between an ipaddress and a string as required.
It looks more complicated than it is due to the many escape characters \ needed in the regular expression to tell the sed command that you’re passing a command and not a character to be matched.