Divide

Divide behaves differently according to the type of the LHS:

  • strings: split by the divider

  • number: arithmetic division

String split

Given a sample.yml file of:

a: cat_meow
b: _

then

yq '.c = .a / .b' sample.yml

will output

a: cat_meow
b: _
c:
  - cat
  - meow

Number division

The result during division is calculated as a float

Given a sample.yml file of:

then

will output

Number division by zero

Dividing by zero results in +Inf or -Inf

Given a sample.yml file of:

then

will output

Last updated

Was this helpful?