Using the sed command s/ foo/\ foo/g seems to work on the 4.2BSD version of sed. Note that the newline character as given by the RETURN key follows the \ on the first line.