post image :date_long | 1 min Read

How to deduplicate elements using jq

####### Input file


some:
  awesome:
    members:
      - green
      - yellow
      - blue
      - red
      - green

####### Deduplication

[arch:devopsinuse main()] yq -o=json eval  /tmp/deduplicate.yaml | jq '.some.awesome.members  | group_by(.) | map(select(length>1) | .[0])'

[
  "green"
]

202406051406

author image

Jan Toth

I have been in DevOps related jobs for past 6 years dealing mainly with Kubernetes in AWS and on-premise as well. I spent quite a lot …

comments powered by Disqus