title: Sed: How to replace a string found after a specific pattern is located in a file
body: <p>If I have the following list in a file:</p>
  
  <pre><code>integer, parameter :: ni = 1024
  integer, parameter :: nj = 256
  integer, parameter :: nk = 16
  </code></pre>
  
  <p>and want to search based on the string 'ni =', and then replace the string that follows (in this case '1024') with a new string like '512' for example (I would like to preserve the space). How can I use sed for this? Note that I would like to just essentially wipe anything that comes after the equal sign, this is because sometimes the string will not be a simple integer, it might be something like '1.D0'. And in some cases there may be comments ahead. So I just want to wipe out whatever is in front of the equal sign and replace with the new value.</p>
  
  <p>The result would be:</p>
  
  <pre><code>integer, parameter :: ni = 512
  integer, parameter :: nj = 256
  integer, parameter :: nk = 16
  </code></pre>