Replace

Replace domain names

Replace an old domain with a new one in bulk.

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.

Open the workspace with this template preloaded, then refine it for your own file and text pattern.

Sample input

proxy_pass https://old.example.com/api;
origin=old.example.com

Prompt 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

domainreplaceurlsconfig

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

  1. 1List the exact domain value that should be replaced everywhere.
  2. 2Use the escaped sed replacement pattern as your starting point.
  3. 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 domain names Sed Template | AskSed