0

I am trying to add a property in a config file, directly under the comment describing the property. Here is my test file:

  # Filename of SSL Certificate

  # Filename of SSL RSA Private Key

  # Filename of SSL Certificate Chain
  ## ssl_certificate_chain=

I want to add

ssl_certificate=/etc/hue/conf/https.cert
directly under the first comment. My first naive approach was to just replace the comment. However, that doesn’t work as the text in the third comment also gets changed, up to the "Chain" text.

So I’m stuck on what sed option to use. I have tried the

a
command in a couple of ways, but I’m fairly new to do this and the volume of similar questions around this
a
command are sending me down a wrong path I think. Here are my attempts. any help is appreciated. Any simlar question to this thats been answered, please point it out. I’ve been looking for a while today.

Using

,
as delimter due to slashes in substitute value

  1. "a,# Filename of SSL Certificate,ssl_certificate=/etc/hue/conf/https.cert,"

Result:

  # Filename of SSL Certificate
,# Filename of SSL Certificate,ssl_certificate=/etc/hue/conf/https.cert,

,# Filename of SSL Certificate,ssl_certificate=/etc/hue/conf/https.cert,
  # Filename of SSL RSA Private Key
,# Filename of SSL Certificate,ssl_certificate=/etc/hue/conf/https.cert,

,# Filename of SSL Certificate,ssl_certificate=/etc/hue/conf/https.cert,
  # Filename of SSL Certificate Chain
,# Filename of SSL Certificate,ssl_certificate=/etc/hue/conf/https.cert,
  ## ssl_certificate_chain=
,# Filename of SSL Certificate,ssl_certificate=/etc/hue/conf/https.cert,

,# Filename of SSL Certificate,ssl_certificate=/etc/hue/conf/https.cert
  1. "s,# Filename of SSL Certificate,a ssl_certificate=/etc/hue/conf/https.cert,"

Result:

  a ssl_certificate=/etc/hue/conf/https.cert

  # Filename of SSL RSA Private Key

  a ssl_certificate=/etc/hue/conf/https.cert Chain
  ## ssl_certificate_chain=
Anonymous Asked question May 14, 2021