Substitute first match per line sed

Replace the first occurrence of 'foo' with 'bar' per line

sed 's/foo/bar/' file.txt