title: Get string between strings in bash
body: <p>I want to get the string between <code>&lt;sometag param='</code> and <code>'&gt;</code></p>
  
  <p>I tried to use the method from <a href="https://stackoverflow.com/questions/8568925/get-any-string-between-2-string-and-assign-a-variable-in-bash">Get any string between 2 string and assign a variable in bash</a> to get the "x":</p>
  
  <pre><code> echo "&lt;sometag param='x'&gt;&lt;irrelevant stuff='nonsense'&gt;" | tr "'" _ | sed -n 's/.*&lt;sometag param=_\(.*\)_&gt;.*/\1/p'
  </code></pre>
  
  <p>The problem (apart from low efficiency because I just cannot manage to escape the apostrophe correctly for sed) is that sed matches the maximum, i.e. the output is:</p>
  
  <pre><code> x_&gt;&lt;irrelevant stuff=_nonsense
  </code></pre>
  
  <p>but the correct output would be the minimum-match, in this example just "x"</p>
  
  <p>Thanks for your help</p>