
次のテキストがあります。
client_encryption_options:
enabled: true
# If enabled and optional is set to true encrypted and unencrypted connections are handled.
optional: false
keystore: conf/.keystore
keystore_password: cassandra
sedコマンドを使用してclient_encryption_optionsの下のキーストア値を変更しようとしています。
sed "/^client_encryption_options:/,+1s/keystore:.*/keystore: \/opt\/test/" $CASSANDRA_YAML_FILE > cassandra.yaml.tmp && mv cassandra.yaml.tmp $CASSANDRA_YAML_FILE
上記のコマンドを試してみると、conf / .keystoreは次のように置き換えられません。/opt/test/
答え1
いいえ、そうではありません。
あなたは私のソリューションを使用しています前の質問。具体的には、次の行の値を変更する方法を尋ねます。この質問には4行を修正する必要があります。
+1
に変更すると、+4
問題が解決する可能性があります。
答え2
sed -e '
/^client_encryption_options:/,/keystore:/!b
//!b
s|\(keystore:\).*|\1 /opt/test|
' < $CASSANDRA_YAML_FILE > cassandra.yaml.tmp && \
mv cassandra.yaml.tmp "$CASSANDRA_YAML_FILE"
「sed」がそれをサポートしている場合は、「-i」(所定の位置で編集)オプションを使用して「mv」を削除することもできます。
sed -i.BAK -e 'your edit commands here' $_YOUR_YAML_FILE # Note: NO redirections here