![파이프된 Unix 명령을 사용하여 파일의 패턴을 영구적으로 바꾸는 방법](https://linux55.com/image/197538/%ED%8C%8C%EC%9D%B4%ED%94%84%EB%90%9C%20Unix%20%EB%AA%85%EB%A0%B9%EC%9D%84%20%EC%82%AC%EC%9A%A9%ED%95%98%EC%97%AC%20%ED%8C%8C%EC%9D%BC%EC%9D%98%20%ED%8C%A8%ED%84%B4%EC%9D%84%20%EC%98%81%EA%B5%AC%EC%A0%81%EC%9C%BC%EB%A1%9C%20%EB%B0%94%EA%BE%B8%EB%8A%94%20%EB%B0%A9%EB%B2%95.png)
다음 줄이 있으므로 구체적으로 바꾸고 싶습니다.
client_encryption_options:
enabled: true
도착하다
client_encryption_options:
enabled: false
client_encryption_options:
enabled: true
# If enabled and optional is set to true, encrypted and unencrypted connections over native transport are handled.
optional: false
keystore: XXXXXX
keystore_password: XXXXX
# Set require_client_auth to true to require two-way host certificate validation
require_client_auth: true
#
# Set truststore and truststore_password if require_client_auth is true
답변1
입력이 YAML 파일이므로 명령줄 YAML 파서를 사용할 수 있습니다 yq
.https://kislyuk.github.io/yq/
yq -y '.client_encryption_options.enabled |= false' file.yml
그러면 enabled
최상위 개체의 키 값이 로 업데이트됩니다.client_encryption_options
false
변경 사항을 적용하려면 해당 옵션 이나 옵션과 yq
함께 사용하세요 .--in-place
-i
이는 yq
JSON 래퍼를 둘러싼 래퍼 jq
이므로 문서에서 주석이 제거됩니다.
yq
에서 제공하는 프로그램을 사용하는 경우https://mikefarah.gitbook.io/yq/, Ubuntu에 설치하는 경우 다음을 yq
사용하십시오 .snap
yq eval '.client_encryption_options.enabled |= false' file.yml
... 내부 편집을 위해 해당 --inplace
또는 옵션을 사용하세요.-i
yq
파일에서 주석이 제거되지는 않습니다 .