Divide behaves differently according to the type of the LHS:
strings: split by the divider
number: arithmetic division
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
The result during division is calculated as a float
Dividing by zero results in +Inf or -Inf
Last updated 3 years ago
a: 12 b: 2.5
yq '.a = .a / .b' sample.yml
a: 4.8 b: 2.5
a: 1 b: -1
yq '.a = .a / 0 | .b = .b / 0' sample.yml
a: !!float +Inf b: !!float -Inf