withif you need to make several updates to the same path.
strenvoperator is a great way to handle special characters in strings:
reduceoperator with the
*(multiply) operator. Note the use of
eval-allto load all files into memory so that they can be merged.
yqto normalise the yaml files and then just use diff. Here is a simple example of using pretty print
-Pto normalise the styling and running diff:
diffand normalise the yaml files as you like.
diffand other bash commands, you can use
<(exp)to pipe in multiple streams of data into
yqwill do is first filter by the selection, and then, separately, update the filtered result and return that subset.
---separators) you can just:
yqhas not yet added
ifexpressions - however you should be able to use
selectto achieve the same outcome. Lets use an example:
ifs like so:
yq- you can get the same result by:
<<:has actually been removed in the 1.2 spec. Thankfully,
yqunderlying yaml parser still supports that tag - and it's extra nice in that it explicitly puts the
!!mergetag on key of the map entry. This tag tells other yaml parsers that this entry is a merge entry, as opposed to a regular string key that happens to have a value of
<<:. This is backwards compatible with the 1.1 spec of yaml, it's simply an explicit way of specifying the type (for instance, you can use a
!!strtag to enforce a particular value to be a string.