title: JQ edit file in place after using JQ Select
body: <p>to edit a json file inplace with JQ like <code>-i</code> in sed I have found many solutions like</p>
  
  <p><code>jq ... input.json &gt; tmp.json &amp;&amp; mv tmp.json input.json</code></p>
  
  <p>This works, but I need to filter on my file, add some data, and place it back in the original. (ie. Update a specific object in a file)</p>
  
  <p>My file contains over 1000 objects with <strong>different <code>Element</code></strong>. I will always be using a filter on <code>Element</code>, I shortened for question. I have a sample file <code>original.json</code> ...</p>
  
  <pre><code>{
    "Element": "acton",
    "objectName": "contacts",
    "Path": "/contacts",
    "Scenario": "",
    "serviceLevel": "",
    "IBM": "",
    "Gap": "",
    "clientPhase": "",
    "parentPhase": "",
    "existsToday": ""
  }
  {
    "Element": "acton",
    "objectName": "optouts",
    "Path": "/optouts",
    "Scenario": "",
    "serviceLevel": "",
    "IBM": "",
    "Dependency": "",
    "Gap": "",
    "clientPhase": "",
    "parentPhase": "",
    "existsToday": ""
  }
  {
    "Element": "acton",
    "objectName": "subscriptionTypes",
    "Path": "/subscription-types",
    "Scenario": "",
    "serviceLevel": "",
    "IBM": "",
    "Dependency": "",
    "Gap": "",
    "clientPhase": "",
    "parentPhase": "",
    "existsToday": ""
  }
  </code></pre>
  
  <p>I want to filter by <code>objectName</code> for <code>contacts</code> add some data to empty IBM field and save to the file</p>
  
  <p>Applying the same logic to inplace edit the IBM field to <code>"Y"</code> on object containing <code>"objectName": "contacts"</code></p>
  
  <p><code>jq 'select(.objectName == "contacts") | .IBM = "Y"' original.json &gt; tmpjson.json &amp;&amp; mv tmpjson.json original.json</code></p>
  
  <p>Now my file <code>original.json</code> shows</p>
  
  <pre><code>{
    "Element": "acton",
    "objectName": "contacts",
    "Path": "/contacts",
    "Scenario": "",
    "serviceLevel": "",
    "IBM": "Y",
    "Dependency": "",
    "Gap": "",
    "clientPhase": "",
    "parentPhase": "",
    "existsToday": ""
  }
  </code></pre>
  
  <p>Expected Result</p>
  
  <pre><code>{
    "Element": "acton",
    "objectName": "contacts",
    "Path": "/contacts",
    "Scenario": "",
    "serviceLevel": "",
    "IBM": "Y",
    "Gap": "",
    "clientPhase": "",
    "parentPhase": "",
    "existsToday": ""
  }
  {
    "Element": "acton",
    "objectName": "optouts",
    "Path": "/optouts",
    "Scenario": "",
    "serviceLevel": "",
    "IBM": "",
    "Dependency": "",
    "Gap": "",
    "clientPhase": "",
    "parentPhase": "",
    "existsToday": ""
  }
  {
    "Element": "acton",
    "objectName": "subscriptionTypes",
    "Path": "/subscription-types",
    "Scenario": "",
    "serviceLevel": "",
    "IBM": "",
    "Dependency": "",
    "Gap": "",
    "clientPhase": "",
    "parentPhase": "",
    "existsToday": ""
  }
  </code></pre>
  
  <p>It seems after using select I can no longer use the provided solution <a href="https://github.com/stedolan/jq/wiki/FAQ#general-questions" rel="noreferrer">https://github.com/stedolan/jq/wiki/FAQ#general-questions</a></p>