Linux tricks, one-liners & shell magic
← Back to all tricks
Replace text in multiple files

Use sed with find to do a batch search-and-replace across many files at once.

bash
$ # Replace 'foo' with 'bar' in all .conf files: find /etc -name '*.conf' -exec sed -i 's/foo/bar/g' {} + # Preview changes first (dry-run): grep -rl 'foo' /etc/*.conf
sedmaster2026-04-19
Delete this trick? This cannot be undone.