-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

0

3 Answers 3

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.

2
  • it had worked this way: sudo sed -i -e '/server.host:/s/: "[^"]"/: "localhost"/' /opt/kibana/config/kibana.yml Commented Mar 16, 2016 at 11:16
  • I picked the arguments for GNU sed. Apparently you're using a different one.
    – kamikaze
    Commented Mar 16, 2016 at 12:37
-1

You can use the following commands

sed

or

awk

0

Not the answer you're looking for? Browse other questions tagged or ask your own question.