What this template solves
This replace-domain template is designed for migrations where the same hostname appears across reverse proxy config, docs, environment files, or scripts.
Sample input
proxy_pass https://old.example.com/api;
origin=old.example.comPrompt to start from
Replace old.example.com with new.example.com in the file
Expected command
sed 's/old\.example\.com/new.example.com/g'Tags
Best for
- Move from an old production domain to a new one.
- Update API hostnames across deployment or proxy files.
- Replace repeated hostnames in documentation and setup scripts.
How to use this template
- 1List the exact domain value that should be replaced everywhere.
- 2Use the escaped sed replacement pattern as your starting point.
- 3Open the template in AskSed if you need to adjust delimiters, paths, or additional context.
Template FAQ
What is the safest way to replace a domain with sed?
The safest approach is to escape dots in the source hostname and use a global replacement, such as `sed 's/old\.example\.com/new.example.com/g'`. This avoids partial matches and keeps repeated hostnames consistent across the file.
Where is a replace-domain template most useful?
It is especially useful during migrations when the same domain appears in proxy config, environment files, deployment scripts, documentation, or API examples and needs to be updated everywhere.
Related templates
Explore nearby sed workflows that target similar replace, cleanup, filtering, or rewrite tasks.
Replace path prefixes
ReplaceReplace an old path prefix with a new one across many lines.
sed 's#/srv/legacy#/srv/current#g'Replace ports in bulk
ReplaceReplace every 8080 in a config with 80.
sed 's/8080/80/g'Replace query parameters
ReplaceReplace one repeated query parameter value with another across many URLs.
sed 's/debug=true/debug=false/g'