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.
You are viewing: What Does Yq Mean
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
Read more : What Does Cheese Grater Mean Sexually
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:
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.
Read more : What Is Braydon Price’s Phone Number
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
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)
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.
Source: https://t-tees.com
Category: WHAT