yq is a portable command-line YAML processor
Clone or download
Permalink
Failed to load latest commit information.
debian Fix version typo Jul 10, 2018
docs Updated mkdocs library Jul 10, 2018
examples Can read from all documents Jul 8, 2018
mkdocs Document multi document read feature Jul 10, 2018
scripts Improved docker build process Oct 25, 2018
snap Version bump Oct 25, 2018
vendor github version of mousetrap required for xcompile Jun 19, 2018
.gitignore Support building snap packages Feb 18, 2018
.travis.yml Task: Upgrade to Golang 1.9 Sep 27, 2017
Dockerfile Improved docker build process Oct 25, 2018
Dockerfile.dev Rename to yq Dec 18, 2017
LICENSE Added License (MIT) Feb 10, 2017
Makefile Add snap target to Makefile Feb 18, 2018
Makefile.variables Rename to yq Dec 18, 2017
README.md Fixed latest linting issues Aug 6, 2018
commands_test.go fixing test lint Oct 25, 2018
data_navigator.go Fixed latest linting issues Aug 6, 2018
data_navigator_test.go Use gopkg managed version of yaml to properly support go get Jun 18, 2018
json_converter.go Use gopkg managed version of yaml to properly support go get Jun 18, 2018
json_converter_test.go Task: Increase test coverage, includes refactor Sep 23, 2017
merge.go Added merge with append Jul 7, 2018
mkdocs.yml Adding delete command documentation May 7, 2018
path_parser.go Task: Simplify development Sep 22, 2017
path_parser_test.go Feature: Add append to array Sep 24, 2017
release_instructions.txt Updated release instructions Oct 30, 2018
test.yml Version bump Oct 25, 2018
utils_test.go Use gopkg managed versions of dependencies, for better go get support Jun 18, 2018
version.go Version bump Oct 25, 2018
version_test.go Incrementing version Jun 20, 2018
yq.go copying file permissions from original file when inline merging - Closes Oct 25, 2018
yq_test.go Can read from all documents Jul 8, 2018

README.md

yq

Build Status Docker Pulls Github Releases (by Release)

a lightweight and portable command-line YAML processor

The aim of the project is to be the jq or sed of yaml files.

Install

On MacOS:

brew install yq

On Ubuntu and other Linux distros supporting snap packages:

snap install yq

On Ubuntu 16.04 or higher from Debian package:

sudo add-apt-repository ppa:rmescandon/yq
sudo apt update
sudo apt install yq -y

or, Download latest binary or alternatively:

go get gopkg.in/mikefarah/yq.v2

Run with Docker

Oneshot use:

docker run -v ${PWD}:/workdir mikefarah/yq yq [flags] <command> FILE...

Run commands interactively:

docker run -it -v ${PWD}:/workdir mikefarah/yq sh

Features

  • Written in portable go, so you can download a lovely dependency free binary
  • Deep read a yaml file with a given path
  • Update a yaml file given a path
  • Update a yaml file given a script file
  • Update creates any missing entries in the path on the fly
  • Create a yaml file given a deep path and value
  • Create a yaml file given a script file
  • Convert from json to yaml
  • Convert from yaml to json
  • Pipe data in by using '-'
  • Merge multiple yaml files where each additional file sets values for missing or null value keys.
  • Merge multiple yaml files and override previous values.
  • Merge multiple yaml files and append array values.
  • Supports multiple documents in a single yaml file

Usage

Check out the documentation for more detailed and advanced usage.

Usage:
  yq [flags]
  yq [command]

Available Commands:
  delete      yq d [--inplace/-i] [--doc/-d index] sample.yaml a.b.c
  help        Help about any command
  merge       yq m [--inplace/-i] [--doc/-d index] [--overwrite/-x] [--append/-a] sample.yaml sample2.yaml
  new         yq n [--script/-s script_file] a.b.c newValue
  read        yq r [--doc/-d index] sample.yaml a.b.c
  write       yq w [--inplace/-i] [--script/-s script_file] [--doc/-d index] sample.yaml a.b.c newValue

Flags:
  -h, --help      help for yq
  -t, --trim      trim yaml output (default true)
  -v, --verbose   verbose mode
  -V, --version   Print version information and quit

Use "yq [command] --help" for more information about a command.

Contribute

  1. scripts/devtools.sh
  2. make [local] vendor
  3. add unit tests
  4. apply changes (use govendor with a preference to gopkg for package dependencies)
  5. make [local] build
  6. If required, update the user documentation
    • Update README.md and/or documentation under the mkdocs folder
    • make [local] build-docs
    • browse to docs/index.html and check your changes
  7. profit