0

I have a conf file like:

mon host = 1.1.1.1
cluster = test

I want to write new ip end of "mon host" like:

mon host = 1.1.1.1, 2.2.2.2
cluster = test

How can i do that?

Morphinz
  • 221
  • 1
  • 2
  • 13

1 Answers1

2

You can easily do it with sed:

sed '/^mon host =/ s/$/, 2.2.2.2/' your.conf

Use -i to change the file instead of printing to STDOUT.

zwer
  • 24,943
  • 3
  • 48
  • 66
  • I dont know why but your command delete inside the file. but this is works "sed 's/mon host = .*/&, 2.2.2.2/' my.conf -i" Thank you for your help. – Morphinz Dec 08 '17 at 12:58