Replace

Replace ports in bulk

Replace every 8080 in a config with 80.

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.

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

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

replaceconfigportsnginx

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

  1. 1Confirm which port value should be replaced across the file.
  2. 2Copy the base sed command or open this template in the AskSed workspace.
  3. 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 ports in bulk Sed Template | AskSed