title: How do I grep and replace string in bash
body: <p>I have a file which contains my json</p>
  <pre><code>{
    &quot;type&quot;: &quot;xyz&quot;,
    &quot;my_version&quot;: &quot;1.0.1.66~22hgde&quot;,
    }
  
  </code></pre>
  <p>I want to edit the value for key my_version and everytime replace the value after third dot with another number which is stored in a variable so it will become something like 1.0.1.32~22hgde. I am using sed to replace it</p>
  <pre><code>sed -i &quot;s/\&quot;my_version\&quot;: \&quot;1.0.1.66~22hgde\&quot;/\&quot;my_version\&quot;: \&quot;1.0.1.$VAR~22hgde\&quot;/g&quot; test.json
  </code></pre>
  <p>This works but the issue is that my_version string doesn't remain constant and it can change and the string can be something like this 1.0.2.66 or 2.0.1.66. So how do I handle such case in bash?</p>