sed -i.bak 's/old/new/g' file.txt

Category: Text Processing

sed -i.bak 's/old/new/g' file.txt

In-place edit with .bak backup created

Edits the file in-place AND creates a backup with .bak extension first, so you can undo if something goes wrong.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.