Well, while this is no INI file, the structure is sufficiently similar, so
crudini may actually help in this case, too.
Code:
$ cat postgresql.conf
# This is a comment
log_connections = yes
log_destination = 'syslog'
search_path = '"$user", public'
shared_buffers = 128MB
$ crudini --set --output=- postgresql.conf '' log_connections no
# This is a comment
log_connections = no
log_destination = 'syslog'
search_path = '"$user", public'
shared_buffers = 128MB
$ crudini --set --output=- postgresql.conf '' datestyle "'iso, mdy'"
# This is a comment
log_connections = yes
log_destination = 'syslog'
search_path = '"$user", public'
shared_buffers = 128MB
datestyle = 'iso, mdy'
OTOH,
Augeas is packaged for EL8 and provides
a lens for posgresql.conf. I'd look into doing this with
augtool. There are also Python and Ruby bindings in
python3-augeas and
ruby-augeas, respectively. And it's supported by Puppet, too.
To give you a perspective on Augeas in RHEL,
here is the relevant discussion at Red Hat Customer Portal.
TBH, now I'm perplexed just as
pan64 was above.
Quote:
Originally Posted by pan64
I don't understand it at all. That range specification is completely pointless here. (ok, the real code can be different)
Code:
sed "/$i/ i FFOOBBAARR"
|
With
postgresql.conf being a flat configuration file without any nested structures, I don't see the point in matching a range inside it. Matching just a line would do the same.