yq/pkg/yqlib/doc/operators/add.md
Mike Farah c38841ce20 wip
2023-04-13 15:40:41 +10:00

474 B

Add

Add behaves differently according to the type of the LHS:

  • arrays: concatenate
  • number scalars: arithmetic addition
  • string scalars: concatenate
  • maps: shallow merge (use the multiply operator (*) to deeply merge)

Use += as a relative append assign for things like increment. Note that .a += .x is equivalent to running .a = .a + .x.

Given a sample.yml file of:

a: hello

then

yq sample.yml

will output

a: hello