sed 's/old/new/' file.txt

Category: Text Processing

sed 's/old/new/' file.txt

Replace first occurrence of 'old' with 'new' per line

Replaces the first occurrence of 'old' with 'new' on each line. sed is a 'stream editor' that processes files line by line.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.