Compare
Deeply compare two yaml documents
Compares the matching yaml nodes at path expression in the two yaml documents. See path expression for more details. Difference calculated line by line, and is printed out line by line where the first character of each line is either:
-
a minus ,indicating the line is not present in the second document (it's removed)+
a plus, indicating that the line is not present in the first document (it's added)
If there are differences then yq
will print out the differences and exit with code 1. If there are no differences, then nothing will be printed and the exit code will be 0.
Example data
Given data1.yaml
and data2.yaml
Basic
Basic will compare the yaml documents 'as-is'
yields
Formatted
Most of the time, it will make sense to format the documents before comparing:
yields
Using path expressions
Use path expressions to compare subsets of yaml documents
yields
Last updated