yq is a portable command-line YAML, JSON, XML, CSV, TOML and properties processor
Go to file
2022-01-22 11:49:12 +11:00
.gitbook/assets GitBook: [#206] deep update example 2021-10-30 03:14:39 +00:00
commands GitBook: [#206] deep update example 2021-10-30 03:14:39 +00:00
operators Updating docs for v4.17.1 release 2022-01-22 11:49:12 +11:00
usage Updating docs for v4.17.1 release 2022-01-22 11:49:12 +11:00
how-it-works.md Tweaking docs 2021-11-03 21:57:50 +11:00
README.md Updating README 2021-11-03 21:51:28 +11:00
SUMMARY.md Docs for 4.16.1 2021-12-04 14:08:16 +11:00
upgrading-from-v3.md GitBook: [#206] deep update example 2021-10-30 03:14:39 +00:00

yq

a lightweight and portable command-line YAML processor. yq uses jq like syntax but works with yaml files as well as json. It doesn't yet support everything jq does - but it does support the most common operations and functions, and more is being added continuously.

yq is written in go - so you can download a dependency free binary for your platform and you are good to go! If you prefer there are a variety of package managers that can be used as well as docker, all listed below.

Quick Usage Guide

Read a value:

yq e '.a.b[0].c' file.yaml

Pipe from STDIN:

cat file.yaml | yq e '.a.b[0].c' -

Update a yaml file, inplace

yq e -i '.a.b[0].c = "cool"' file.yaml

Update using environment variables

NAME=mike yq e -i '.a.b[0].c = strenv(NAME)' file.yaml

Merge multiple files

yq ea '. as $item ireduce ({}; . * $item )' path/to/*.yml

Multiple updates to a yaml file

yq e -i '
  .a.b[0].c = "cool" |
  .x.y.z = "foobar" |
  .person.name = strenv(NAME)
' file.yaml

Install

See the github page for the various ways you can install and use yq

Known Issues / Missing Features

See tips and tricks for more common problems and solutions.