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

Category: Text Processing

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

Edit file in-place replacing all occurrences

Edits the file directly on disk (in-place) instead of just printing the result. -i means 'in-place'. Without -i, sed only prints changes.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.