Skip to the content.

08. September 2025 - verfasst von Oliver Gaida - Kategorien: ["yaml"]

merge yaml files

given a file a.yml:

a: []
b: 1
c: 
- 4
- 5

create json with jo:

jo a="$(jo -a 12 17)" c="$(jo -a "a b" "c d")"
# => {"a":[12,17],"c":["a b","c d"]}

merge it:

jq -s '.[0] * .[1]' <(yq . a.yaml) <(jo a="$(jo -a 12 17)" c="$(jo -a "a b" "c d")")|yq -y .

gives:

a:
  - 12
  - 17
b: 1
c:
  - a b
  - c d

a and c have been overwritten.

HOME