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.ymlwill output
a: cat_meow
b: _
c:
  - cat
  - meowNumber division
The result during division is calculated as a float
Given a sample.yml file of:
a: 12
b: 2.5then
yq '.a = .a / .b' sample.ymlwill output
a: 4.8
b: 2.5Number division by zero
Dividing by zero results in +Inf or -Inf
Given a sample.yml file of:
a: 1
b: -1then
yq '.a = .a / 0 | .b = .b / 0' sample.ymlwill output
a: !!float +Inf
b: !!float -InfLast updated
Was this helpful?