-1

i am trying to build a Bash file.

one of the commands is:

sudo vi /opt/kibana/config/kibana.yml

How can i change Automaticaly this text line :

server.host: "0.0.0.0"

with this text line:

server.host: "localhost" 

tnx

Andrey

Andrew Ramnikov
  • 783
  • 2
  • 9
  • 30

3 Answers3

1

you can search and replace text from within the vi text editor using the following command

:%s/0.0.0.0/localhost/

more info

0

Beware, untested!

sed -ri .bak '/server.host:/s/: *"[^"]*"/: "localhost"/' /opt/kibana/config/kibana.yml

To test it run it without -i .bak and the change is output on stdout instead of changing the file. -i .bak causes in-place editing and the creation of a backup file.

kamikaze
  • 1,529
  • 8
  • 18
-1

You can use the following commands

sed

or

awk