title: How to Add / Replace array elements with "yq" conditionally
body: <p>I am looking for some help with using &quot;yq&quot; to replace / add existing array elements by name. Also conditionally? Appreciate your help in this regard.</p>
  <p>I have tried the below so far.. but this just merges and I am getting duplicates when I rerun this after updates.</p>
  <pre><code>yq eval-all '... comments=&quot;&quot; | . as $item ireduce ({}; . *+ $item)' kong-oauth.yaml kong-apikey.yaml
  </code></pre>
  <p>Following scenario, I like to updated &quot;Master.yaml&quot; 'services' array only by name.</p>
  <p><strong>Master.yaml</strong></p>
  <pre><code>services:
   - name: service1
     url: https://service1.microservice.net
   - name: service2
     url: https://service2.microservice.net
  </code></pre>
  <hr />
  <p><strong>service3.yaml</strong></p>
  <pre><code>services:
   - name: service3
     url: https://service3.microservice.net
  </code></pre>
  <hr />
  <p><strong>service2.yaml</strong></p>
  <pre><code>services:
   - name: service2
     url: https://service22.microservice.net
  </code></pre>
  <hr />
  <p><strong>Expected YAML</strong></p>
  <pre><code>services:
   - name: service1
     url: https://service1.microservice.net
   - name: service2
     url: https://service22.microservice.net
   - name: service3
     url: https://service3.microservice.net
  </code></pre>
  <p>Thanks
  Sanjay</p>