2016-06-21 29 views
0

以下のコンテンツを持つファイルがあります。以下のコードで一部の値のみを変更したいと思います。ファブリック内の特定のフィールド値を置き換えます。

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" の値を変更したいです。

答えて

1

あなたはsedを使用することができ、例:

def sed_ip(): 
    sed('/home/user/test/file', 'primary_private_IP_address', '192.168.0.0') 
関連する問題