我有以下内容的文件我想在下面的代码中只更改一些值。我可以在结构中进行。
totem {
version: 2
cluster_name: lbcluster
transport: udpu
interface {
ringnumber: 0
bindnetaddr: server_private_IP_address
broadcast: yes
mcastport: 5405
}
}
quorum {
provider: corosync_votequorum
two_node: 1
}
nodelist {
node {
ring0_addr: primary_private_IP_address
name: primary
nodeid: 1
}
node {
ring0_addr: secondary_private_IP_address
name: secondary
nodeid: 2
}
}
logging {
to_logfile: yes
logfile: /var/log/corosync/corosync.log
to_syslog: yes
timestamp: on
}
我只想更改" secondary_private_IP_address" &安培; " primary_private_IP_address" &安培; " server_private_IP_address"来自此文件的值。
答案 0 :(得分:1)
您可以使用sed,例如:
def sed_ip():
sed('/home/user/test/file', 'primary_private_IP_address', '192.168.0.0')