Linux sed and awk Cheat Sheet/Edit a file in place

Modify the original file directly.

Section: sed Substitution

Edit a file in place

bash
bash
sed -i 's/debug/info/g' app.conf
Explanation

In-place editing is powerful; consider keeping backups before bulk changes.

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
Edit in place with backup
Create a backup copy while editing.
OpenIn sheetbashsame section
Replace first occurrence per line
Substitute one match in each line.
OpenIn sheetbashsame section
Replace all occurrences per line
Substitute every match on each line.
OpenIn sheetbashsame section
Use an alternate delimiter
Make path replacements easier to read.
OpenIn sheetbashsame section
Delete blank lines
Remove empty lines from output.
OpenIn sheetbash1 tag match
Delete comment lines
Skip lines that begin with `#`.
OpenIn sheetbash1 tag match