yq v4 tools

1 min read
Table of contents
Few operators :
Length
We can get the length of an array using this length operator
apple: - test: "eat" - test: "cut"
Then the following command gives us the length
length=$(yq '.apple | length' test.yaml)
env
This is used to pass variables while using yq
here are a few examples :
capitalOfIndia=$(country="India" yq '.[env(country)].capital' test.yaml)
unique, sort
Unique or/and Sort can be used with the help of pipe operator "|".
|, |=, +, +=
|
Typically used to derive block of yaml
|=
Used to update specific block of yaml
+=
To Add a new entry and modify the parent yaml block as well
- To just add new entry but not update original
Test
0
Subscribe to my newsletter
Read articles from SUJAY PUJARI directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
