What this template solves
This sed template helps when you need to replace the same port across config files, reverse proxies, or local environment samples without editing every line manually.
Sample input
server 127.0.0.1:8080;
proxy_pass http://localhost:8080;Prompt to start from
Replace every 8080 in the config file with 80
Expected command
sed 's/8080/80/g'Tags
Best for
- Update nginx or Apache examples from 8080 to 80.
- Normalize local development ports before deployment.
- Rewrite repeated ports inside docs, compose files, or scripts.
How to use this template
- 1Confirm which port value should be replaced across the file.
- 2Copy the base sed command or open this template in the AskSed workspace.
- 3Preview on sample text first, then run the macOS or Linux file-edit command.
Template FAQ
What is the fastest sed pattern for replacing ports across a config file?
For repeated exact values such as 8080 to 80, a global replacement like `sed 's/8080/80/g'` is the usual starting point. AskSed wraps that into a template page so you can preview the change and move into macOS or Linux file-edit commands safely.
When should I use a replace-port sed template instead of editing the file manually?
Use it when the same port appears many times in reverse proxy config, environment samples, deployment docs, or scripts. It reduces manual mistakes and keeps the rewrite consistent across every line.
Related templates
Explore nearby sed workflows that target similar replace, cleanup, filtering, or rewrite tasks.
Replace domain names
ReplaceReplace an old domain with a new one in bulk.
sed 's/old\.example\.com/new.example.com/g'Replace path prefixes
ReplaceReplace an old path prefix with a new one across many lines.
sed 's#/srv/legacy#/srv/current#g'Delete empty lines
CleanupRemove blank and whitespace-only lines.
sed '/^\s*$/d'