G
G
gremlintv22017-08-06 22:02:36
linux
gremlintv2, 2017-08-06 22:02:36

How to replace a line via sed in a file?

There is a file:
/var/lib/pgsql/9.4/data/postgresql.conf
it needs to be replaced like this:
Change #listen_addresses = 'localhost' to listen_addresses = '*'
Change #port = 5432 to port = 5432
how to implement it?
PS: Am I the only lazy one? Or maybe they have already "invented the wheel" and there is some kind of tool that will set up the system according to a template, without writing your own bash lines that are executed on a semiautomatic device?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Saboteur, 2017-08-06
@gremlintv2

look at ansible, there is such a thing.
well, so

sed -i /var/lib/pgsql/9.4/data/postgresql.conf -e "s/#listen_addresses = 'localhost'/listen_adresses = '*'/"
sed -i /var/lib/pgsql/9.4/data/postgresql.conf -e "s/#port = 5432/port = 5432/"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question