Substitute first match per line

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

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

tool
sed15 commands
tags
sedlinux

More sed commands

all 15 sed commands