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 Shoes To Wear With A Black Dress

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 Color Comforter Goes With Grey Walls

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 Is Cpi Training For Special Education

We take a look at what CPI is and why it is so beneficial for de-escalating crises for children with autism in combination with several ABA strategies.You…

What Is 1 15 As A Decimal

Converting 1/15 to a decimal is quite possibly one of the easiest calculations you can make. In this (very short) guide, we’ll show you how to turn…

What Is Coryxkenshin Net Worth

What Is Coryxkenshin Net Worth

You may be interested What Is A Ham Roast What Does Pre Awa Mean What Is A Catless Downpipe What Happens If You Don’t Pay Visitax What…

What Time Is 22 45

Convert 2245 military time into standard (regular) AM/PM format. You may be interested What Would My Stepchild Child Be To My Neiece What Color Is Heather Gray…

What Do Dental Implants Look Like

With changing technology, dental implants have become a go-to alternative to some other procedures. Dental implants work by replacing missing teeth as well as keeping prosthetics, like…

What Channel Is Cbs Uverse

Are you a fan of CBS shows and wondering if you can access them on AT&T? Well, you’re in luck! AT&T offers an exciting lineup of CBS…