Yq
yq 是一个命令行 YAML 处理器
# Windowsscoop install yqyq 使用类似 jq 的路径来访问字段
测试文件为 example.yaml
test: key: value array: - 114514 - 1919180# 查询,输出 valueyq '.test.key' example.yaml# 查询,输出 114514yq '.test.array[0]' example.yaml# 修改,输出中 value 被修改为 new-valueyq '.test.key = "new-value"' example.yaml# 将输出写入文件yq '.test.key = "new-value"' example.yaml > new.yaml# 或者直接修改文件yq -i '.test.key = "new-value"' example.yaml# YAML 转 JSONyq -o json example.yaml > example.json# JSON 转 YAMLyq -o yaml example.json > example.yaml