title: Search and replace with sed
body: <p>Last week I accidently externalized all my strings of my eclipse project. I need to revert this and my only hope is sed. I tried to create scripts but failed pathetically because I'm new with sed and this would be a very complicated operation. What I need to do is this:</p>
  
  <p>Strings in <code>class.java</code> file is currently in the following format(method) <code>Messages.getString(&lt;key&gt;)</code>. Example :</p>
  
  <pre><code>    if (new File(DataSource.DEFAULT_VS_PATH).exists()) {
          for (int i = 1; i &lt;= c; i++) {
              if (!new File(DataSource.DEFAULT_VS_PATH
                      + Messages.getString("VSDataSource.89") + i).exists()) { //$NON-NLS-1$
                  getnewvfspath = DataSource.DEFAULT_VS_PATH
                          + Messages.getString("VSDataSource.90") + i; //$NON-NLS-1$
                  break;
              }
          }
      }
  </code></pre>
  
  <p>The key and matching Strings are in <code>messages.properties</code> file in the following format.</p>
  
  <pre><code>VSDataSource.92=No of rows in db = 
  VSDataSource.93=Verifying db entry : 
  VSDataSource.94=DB is open
  VSDataSource.95=DB is closed
  VSDataSource.96=Invalid db entry for 
  VSDataSource.97=\ removed.
  key=string
  </code></pre>
  
  <p>So I need the java file back in this format:</p>
  
  <pre><code>    if (new File(DataSource.DEFAULT_VS_PATH).exists()) {
          for (int i = 1; i &lt;= c; i++) {
              if (!new File(DataSource.DEFAULT_VS_PATH
                      + "String 2" + i).exists()) { //$NON-NLS-1$
                  getnewvfspath = DataSource.DEFAULT_VS_PATH
                          + "String 1" + i; //$NON-NLS-1$
                  break;
              }
          }
      }
  </code></pre>
  
  <p>How can I accomplish this with <code>sed</code>? Or is there an easier way?</p>