Substitute one match in each line.
Section: sed Substitution
Replace first occurrence per line
bash
bash
sed 's/foo/bar/' file.txtExplanation
By default, sed replaces only the first match on each line.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing sed Substitution