Skip to content

Instantly share code, notes, and snippets.

@lski
Created December 8, 2020 14:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lski/75795922aa6d446ae479d4ff623c2b3b to your computer and use it in GitHub Desktop.
Save lski/75795922aa6d446ae479d4ff623c2b3b to your computer and use it in GitHub Desktop.
Changes the port in nginx in the file. Only for simple replacements.
PORT=${1:-80}
FILE=${2:-/etc/nginx/conf.d/default.conf}
# Replace the port number, retaining whitespace
sed -i 's|\([\s]*listen\) *[0-9]*;|\1 '$PORT';|g' "$FILE"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment