shell脚本在regex linux中查找和替换

时间:2017-03-24 12:40:44

标签: regex linux shell

我需要找一个单词并替换其他单词,但它的作用对我来说

Edit.sh:

#! /bin/sh
file=kibana.yml
addr="   192.168.1.101"
sed -i -s -e "s/\(server.host:\).*/\1$addr/" $file
elaurl="http://192.168.1.100:9200"
sed -i -s -e "s/\(elasticsearch.url:\)/*/.*/\1$elaurl/"  $file

kibana.yml:

# The host to bind the server to.
   server.host:   192.168.1.101

# If you are running kibana behind a proxy, and want to mount it at a path,
# specify that path here. The basePath can't end in a slash.
# server.basePath: ""

# The maximum payload size in bytes on incoming server requests.
# server.maxPayloadBytes: 1048576

# The Elasticsearch instance to use for all your queries.
  elasticsearch.url: http://10.1.2.19:9200

但是,如果我只尝试替换server.host:它工作正常,但添加下一个(elasticsearch.url :)行然后抛出错误:

  sed: -e expression #1, char 28: unknown option to `s'

建议我如何解决此问题

0 个答案:

没有答案