Skip to main content
1 of 4
Shr00m
  • 11
  • 1
  • 2

sed command to replace a value in a config file

I'm working on an automation script and I need to change the value in a config file. The config file that I'm trying to edit has multiple lines one of which is this (including the spaces before):

    "peer-port": 23456,
 

The script that I'm writing will pass a new port that is stored in a variable called $newport. How can use a sed (or awk) command to replace "23456" with the new port value contained in the variable $newport?

Thanks!!

Shr00m
  • 11
  • 1
  • 2