2020-11-20 01:22:35 +00:00
|
|
|
# yq
|
|
|
|
# A lightweight and portable command-line YAML processor
|
|
|
|
|
2020-11-21 15:40:31 +00:00
|
|
|
# This is for yq v3. For version 4, use 'yq_v4'
|
|
|
|
|
2020-11-20 01:22:35 +00:00
|
|
|
# Read spec.template node from example.yml
|
|
|
|
yq r example.yml spec.template
|
|
|
|
|
|
|
|
# Read from stdin
|
|
|
|
cat sample.yaml | yq r - b.c
|
|
|
|
|
|
|
|
# Print the path
|
|
|
|
yq r --printMode p "a.thing*.*"
|
|
|
|
|
|
|
|
# Print the path and value
|
|
|
|
yq r --printMode pv "a.thing*.*"
|
|
|
|
|
|
|
|
# Print the length of a list
|
|
|
|
yq r sample.yml --length animals
|
|
|
|
|
|
|
|
# Read with conditions
|
|
|
|
yq r sample.yml spec.metadata[name==myapp]
|
|
|
|
|
|
|
|
# Collect results into an array
|
|
|
|
yq r sample.yaml --collect a.*.animal
|
|
|
|
|
2021-06-08 15:03:13 +00:00
|
|
|
# Read from the 2nd document
|
2020-11-20 01:22:35 +00:00
|
|
|
yq r -d1 sample.yaml b.c
|
|
|
|
|
|
|
|
# Validate a document
|
|
|
|
yq v valid.yaml
|
|
|
|
|
|
|
|
# Compare documents
|
|
|
|
yq compare data1.yaml data2.yaml
|
|
|
|
|
|
|
|
# Write b.c value with 'cat'
|
|
|
|
yq w sample.yaml b.c cat
|
|
|
|
|
|
|
|
# Delete b.c node in place from sample.yaml
|
|
|
|
yq d -i sample.yaml b.c
|
|
|
|
|
|
|
|
# Merge documents
|
|
|
|
yq merge data1.yaml data2.yaml
|
|
|
|
|
|
|
|
# Shell completion
|
|
|
|
yq shell-completion
|