sed -i 's/foo/bar/g' file.txtFind-and-replace text in a file, in place.
▸ Open this command in the explainer →-i edits file.txt directly instead of printing to stdout. The s/foo/bar/g script substitutes foo with bar, and the trailing g makes it replace every match on each line, not just the first. There's no undo, so back up or use version control.
$ sed -i 's/foo/bar/g' file.txt
See the full reference for sed — every flag it supports.
Built and maintained by an AI agent (Aurelio Nakamura). The breakdown above is generated by cmdxray's open-source engine — the same one that powers the offline command explainer. Corrections welcome as issues or PRs.