What Does Yq Mean

Build Docker Pulls Github Releases (by Release) Go Report CodeQL

a lightweight and portable command-line YAML, JSON and XML processor. yq uses jq like syntax but works with yaml files as well as json, xml, properties, csv and tsv. 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 and Podman, all listed below.

Read a value:

Pipe from STDIN:

Update a yaml file, in place

Update using environment variables

Merge multiple files

Multiple updates to a yaml file

Find and update an item in an array:

Convert JSON to YAML

See recipes for more examples and the documentation for more information.

Take a look at the discussions for common questions, and cool ideas

Use wget to download, gzipped pre-compiled binaries:

For instance, VERSION=v4.2.0 and BINARY=yq_linux_amd64

Using Homebrew

yq installs with strict confinement in snap, this means it doesn’t have direct access to root files. To read root files you can:

And to write to a root file you can either use sponge:

Refer to more articles:  What Percent Is 9 Of 15

or write to a temporary file:

Note that you can run yq in docker without network access and other privileges if you desire, namely -security-opt=no-new-privileges -cap-drop all -network none.

You’ll need to pass the -i-interactive flag to docker:

It can be useful to have a bash function to avoid typing the whole docker command:

yq’s container image no longer runs under root (#860). If you’d like to install more things in the container image, or you’re having permissions issues when attempting to read/write files you’ll need to either:

Or, in your Dockerfile:

By default, the alpine image yq uses does not include timezone data. If you’d like to use the tz operator, you’ll need to include this data:

If you are using podman with SELinux, you will need to set the shared volume flag :z on the volume mount:

See https://mikefarah.gitbook.io/yq/usage/github-action for more.

As these are supported by the community ❤️ – however, they may be out of date with the officially supported releases.

Please note that the Debian package (previously supported by @rmescandon) is no longer maintained. Please use an alternative installation method.

See here

See webi Supported by @adithyasunil26 (https://github.com/webinstall/webi-installers/tree/master/yq)

Using Chocolatey

Chocolatey Chocolatey

Supported by @chillum (https://chocolatey.org/packages/yq)

Using scoop

Using winget

Using MacPorts

Supported by @herbygillot (https://ports.macports.org/maintainer/github/herbygillot)

  • Enable edge/community repo by adding $MIRROR/alpine/edge/community to /etc/apk/repositories
  • Update database index with apk update
  • Install yq with apk add yq

Supported by Tuan Hoang https://pkgs.alpinelinux.org/package/edge/community/x86/yq

  • Detailed documentation with many examples
  • Written in portable go, so you can download a lovely dependency free binary
  • Uses similar syntax as jq but works with YAML, JSON and XML files
  • Fully supports multi document yaml files
  • Supports yaml front matter blocks (e.g. jekyll/assemble)
  • Colorized yaml output
  • Date/Time manipulation and formatting with TZ
  • Deeply data structures
  • Sort keys
  • Manipulate yaml comments, styling, tags and anchors and aliases.
  • Update in place
  • Complex expressions to select and update
  • Keeps yaml formatting and comments when updating (though there are issues with whitespace)
  • Decode/Encode base64 data
  • Load content from other files
  • Convert to/from json/ndjson
  • Convert to/from xml
  • Convert to/from properties
  • Convert to/from csv/tsv
  • General shell completion scripts (bash/zsh/fish/powershell)
  • Reduce to merge multiple files or sum an array or other fancy things.
  • Github Action to use in your automated pipeline (thanks @devorbitus)
Refer to more articles:  What Is An Ibu Ancient Egypt

Check out the documentation for more detailed and advanced usage.

  • yq attempts to preserve comment positions and whitespace as much as possible, but it does not handle all scenarios (see https://github.com/go-yaml/yaml/tree/v3 for details)
  • Powershell has its own…opinions on quoting yq
  • “yes”, “no” were dropped as boolean values in the yaml 1.2 standard – which is the standard yq assumes.

See tips and tricks for more common problems and solutions.

Related Posts

What Does Blue Underwear Mean On New Year's

What Does Blue Underwear Mean On New Year’s

New Year’s Eve is a time for celebration, reflection, and setting intentions for the year ahead. While many people focus on their outfits and accessories for the…

What Time Is Sentencing For Murdaugh

Alex Murdaugh’s theft of millions of dollars was about to be revealed so he killed his wife and son to buy time to figure a way out,…

What Is Hard Salami

Salami is a beloved deli meat, celebrated for its rich, savory flavors and versatility in various culinary creations. Among the myriad of salami varieties, Hard and Genoa…

What Is A Disposition Letter From A Landlord

As a landlord, returning a tenant’s security deposit after they move out is a task you’re inevitably very familiar with. This task involves inspecting the unit, assessing…

What Is The Purpose Of A Company's Data Strategy

What Is The Purpose Of A Company’s Data Strategy

You may be interested What Is A Fairy Stone What Is Sleeping Beauty Turquoise What Is Shimming What Does Cheese Grater Mean Sexually What Is A Terebinth…

What Is Heart To Heart By Mac Demarco About

What Is Heart To Heart By Mac Demarco About

Mac Miller, Steve Lacy, Mac DeMarco (2018). Mac DeMarco’s “Heart to Heart”, off his 2019 album Here Comes the Cowboy, has become one of the most popular…