Task-oriented command line recipes ยท no files stored on this domain
CliWorks

Stream edits over a file, in place or not.

sed

Edit a copy first

sed 's/old/new/' file.txt > file.txt.new && mv file.txt.new file.txt

Edit in place safely

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

-i.bak keeps a backup. A plain -i leaves nothing to roll back to.

Match whole lines, not substrings

sed -n '/^ERROR/p' app.log

Strip a prefix across many files

find . -name '*.conf' -exec sed -i.bak 's|localhost|db.internal|g' {} +

Scope: sed