我正在尝试将 YAML 文件的第 3 层嵌套值更改为File 的当前bind_host: localhost
值bind_host: 0.0.0.0
bind_host
server:
application_connectors:
- type: http
port: 8989
bind_host: localhost
request_log:
appenders: []
admin_connectors:
- type: http
port: 8990
bind_host: localhost
预期产出
server:
application_connectors:
- type: http
port: 8989
bind_host: 0.0.0.0
request_log:
appenders: []
admin_connectors:
- type: http
port: 8990
bind_host: 0.0.0.0
我在尝试
awk '
/:$/{
flag=""
}
/server/{
flag=1
}
flag && NF && (/bind_host:/){
match($0,/^[[:space:]]+/);
val=substr($0,RSTART,RLENGTH);
$NF="0.0.0.0";
print val $0;
next
}
1
' config.yml