title: Parse a text file for certain string with prefix "Product Name:"
body: <p>Hey guys I've got a text file that a script creates (specifically <code>dmidecode &gt; dmidecode.txt</code>) and I want to be able to grab the contents of "Product Name:" so in this case "HP t5740e Thin Client" but it will be slightly different for other machine types.  I could just use <code>sed</code> to count to line 44 and then slice it up until I get what I want but I'd like for it to be more dynamic than that.</p>
  
  <p>Text file:</p>
  
  <pre><code>41  Handle 0x0001, DMI type 1, 27 bytes
  42  System Information
  43      Manufacturer: Hewlett-Packard
  44      Product Name: HP t5740e Thin Client
  45      Version:   
  46      Serial Number: CNW1160BZ7
  47      UUID: A0B86400-6BBD-11E0-8325-92EEE331A344
  48      Wake-up Type: Power Switch
  49      SKU Number: XL424AA#ABA
  50      Family: 103C_53302C
  </code></pre>
  
  <p>Code I have that doesn't seem to work:</p>
  
  <pre><code>sed -c -i "s/\($TARGET_KEY *Product Name :*\).*/\1$REPLACEMENT_VALUE/" dmidecode.txt
  </code></pre>
  
  <p>I get the feeling my regular expressions is way off (probably because the initial examples I looked at tainted my "vision") </p>
  
  <p>Any help is greatly appreciated!
  Also, anyone know of any good regular expression references I can check out?</p>
  
  <p>UPDATE:
  Ok I was able to spend a little more time on this, found some better examples and got this out of my research:</p>
  
  <pre><code>grep -e "Product Name: HP" -e "Product Name: hp" dmidecode.txt | awk '{print}'
  </code></pre>
  
  <p>When I add <code>'{print $NF}'</code> it prints just the last word, is there a way to modify print to include everything after the search string instead of the whole line itself?</p>
  
  <p>Also, I should have noted this from the beginning, but I need the output to go into a variable.</p>