title: sed command not working within ruby but it works in terminal
body: <p>I'm having a problem with this line of sed when i run it from within a ruby script:</p>
  
  <pre><code>sed -ne '/^&lt;div class="results"&gt;/,/&lt;\/body&gt;/p' blah.html
  </code></pre>
  
  <p>I'm trying to run it within backticks `` but it won't execute properly from within a Ruby script. The contents of blah.html are as follows...</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"&gt;
  &lt;head&gt;
    &lt;title&gt;RSpec results&lt;/title&gt;
    &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
    &lt;meta http-equiv="Expires" content="-1" /&gt;
    &lt;meta http-equiv="Pragma" content="no-cache" /&gt;
    &lt;style type="text/css"&gt;
    body {
      margin: 0;
      padding: 0;
      background: #fff;
      font-size: 80%;
    }
    &lt;/style&gt;
    &lt;script type="text/javascript"&gt;
      // &lt;![CDATA[
  
  function addClass(element_id, classname) {
    document.getElementById(element_id).className += (" " + classname);
  }
  
  function removeClass(element_id, classname) {
    var elem = document.getElementById(element_id);
    var classlist = elem.className.replace(classname,'');
    elem.className = classlist;
  }
  
  function moveProgressBar(percentDone) {
    document.getElementById("rspec-header").style.width = percentDone +"%";
  }
  
  function makeRed(element_id) {
    removeClass(element_id, 'passed');
    removeClass(element_id, 'not_implemented');
    addClass(element_id,'failed');
  }
  
  function makeYellow(element_id) {
    var elem = document.getElementById(element_id);
    if (elem.className.indexOf("failed") == -1) {  // class doesn't includes failed
      if (elem.className.indexOf("not_implemented") == -1) { // class doesn't include not_implemented
        removeClass(element_id, 'passed');
        addClass(element_id,'not_implemented');
      }
    }
  }
  
  function apply_filters() {
    var passed_filter = document.getElementById('passed_checkbox').checked;
    var failed_filter = document.getElementById('failed_checkbox').checked;
    var pending_filter = document.getElementById('pending_checkbox').checked;
  
    assign_display_style("example passed", passed_filter);
    assign_display_style("example failed", failed_filter);
    assign_display_style("example not_implemented", pending_filter);
  
    assign_display_style_for_group("example_group passed", passed_filter);
    assign_display_style_for_group("example_group not_implemented", pending_filter, pending_filter || passed_filter);
    assign_display_style_for_group("example_group failed", failed_filter, failed_filter || pending_filter || passed_filter);
  }
  
  function get_display_style(display_flag) {
    var style_mode = 'none';
    if (display_flag == true) {
      style_mode = 'block';
    }
    return style_mode;
  }
  
  function assign_display_style(classname, display_flag) {
    var style_mode = get_display_style(display_flag);
    var elems = document.getElementsByClassName(classname)
    for (var i=0; i&lt;elems.length;i++) {
      elems[i].style.display = style_mode;
    }
  }
  
  function assign_display_style_for_group(classname, display_flag, subgroup_flag) {
    var display_style_mode = get_display_style(display_flag);
    var subgroup_style_mode = get_display_style(subgroup_flag);
    var elems = document.getElementsByClassName(classname)
    for (var i=0; i&lt;elems.length;i++) {
      var style_mode = display_style_mode;
      if ((display_flag != subgroup_flag) &amp;&amp; (elems[i].getElementsByTagName('dt')[0].innerHTML.indexOf(", ") != -1)) {
        elems[i].style.display = subgroup_style_mode;
      } else {
        elems[i].style.display = display_style_mode;
      }
    }
  }
  
      // ]]&gt;
    &lt;/script&gt;
    &lt;style type="text/css"&gt;
  #rspec-header {
    background: #65C400; color: #fff; height: 4em;
  }
  
  .rspec-report h1 {
    margin: 0px 10px 0px 10px;
    padding: 10px;
    font-family: "Lucida Grande", Helvetica, sans-serif;
    font-size: 1.8em;
    position: absolute;
  }
  
  #label {
    float:left;
  }
  
  #display-filters {
    float:left;
    padding: 28px 0 0 40%;
    font-family: "Lucida Grande", Helvetica, sans-serif;
  }
  
  #summary {
    float:right;
    padding: 5px 10px;
    font-family: "Lucida Grande", Helvetica, sans-serif;
    text-align: right;
  }
  
  #summary p {
    margin: 0 0 0 2px;
  }
  
  #summary #totals {
    font-size: 1.2em;
  }
  
  .example_group {
    margin: 0 10px 5px;
    background: #fff;
  }
  
  dl {
    margin: 0; padding: 0 0 5px;
    font: normal 11px "Lucida Grande", Helvetica, sans-serif;
  }
  
  dt {
    padding: 3px;
    background: #65C400;
    color: #fff;
    font-weight: bold;
  }
  
  dd {
    margin: 5px 0 5px 5px;
    padding: 3px 3px 3px 18px;
  }
  
  dd .duration {
    padding-left: 5px;
    text-align: right;
    right: 0px;
    float:right;
  }
  
  dd.example.passed {
    border-left: 5px solid #65C400;
    border-bottom: 1px solid #65C400;
    background: #DBFFB4; color: #3D7700;
  }
  
  dd.example.not_implemented {
    border-left: 5px solid #FAF834;
    border-bottom: 1px solid #FAF834;
    background: #FCFB98; color: #131313;
  }
  
  dd.example.pending_fixed {
    border-left: 5px solid #0000C2;
    border-bottom: 1px solid #0000C2;
    color: #0000C2; background: #D3FBFF;
  }
  
  dd.example.failed {
    border-left: 5px solid #C20000;
    border-bottom: 1px solid #C20000;
    color: #C20000; background: #FFFBD3;
  }
  
  
  dt.not_implemented {
    color: #000000; background: #FAF834;
  }
  
  dt.pending_fixed {
    color: #FFFFFF; background: #C40D0D;
  }
  
  dt.failed {
    color: #FFFFFF; background: #C40D0D;
  }
  
  
  #rspec-header.not_implemented {
    color: #000000; background: #FAF834;
  }
  
  #rspec-header.pending_fixed {
    color: #FFFFFF; background: #C40D0D;
  }
  
  #rspec-header.failed {
    color: #FFFFFF; background: #C40D0D;
  }
  
  
  .backtrace {
    color: #000;
    font-size: 12px;
  }
  
  a {
    color: #BE5C00;
  }
  
  /* Ruby code, style similar to vibrant ink */
  .ruby {
    font-size: 12px;
    font-family: monospace;
    color: white;
    background-color: black;
    padding: 0.1em 0 0.2em 0;
  }
  
  .ruby .keyword { color: #FF6600; }
  .ruby .constant { color: #339999; }
  .ruby .attribute { color: white; }
  .ruby .global { color: white; }
  .ruby .module { color: white; }
  .ruby .class { color: white; }
  .ruby .string { color: #66FF00; }
  .ruby .ident { color: white; }
  .ruby .method { color: #FFCC00; }
  .ruby .number { color: white; }
  .ruby .char { color: white; }
  .ruby .comment { color: #9933CC; }
  .ruby .symbol { color: white; }
  .ruby .regex { color: #44B4CC; }
  .ruby .punct { color: white; }
  .ruby .escape { color: white; }
  .ruby .interp { color: white; }
  .ruby .expr { color: white; }
  
  .ruby .offending { background-color: gray; }
  .ruby .linenum {
    width: 75px;
    padding: 0.1em 1em 0.2em 0;
    color: #000000;
    background-color: #FFFBD3;
  }
  
    &lt;/style&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;div class="rspec-report"&gt;
  
  &lt;div id="rspec-header"&gt;
    &lt;div id="label"&gt;
      &lt;h1&gt;RSpec Code Examples&lt;/h1&gt;
    &lt;/div&gt;
  
    &lt;div id="display-filters"&gt;
      &lt;input id="passed_checkbox" name="passed_checkbox" type="checkbox" checked onchange="apply_filters()" value="1"&gt; &lt;label for="passed_checkbox"&gt;Passed&lt;/label&gt;
      &lt;input id="failed_checkbox" name="failed_checkbox" type="checkbox" checked onchange="apply_filters()" value="2"&gt; &lt;label for="failed_checkbox"&gt;Failed&lt;/label&gt;
      &lt;input id="pending_checkbox" name="pending_checkbox" type="checkbox" checked onchange="apply_filters()" value="3"&gt; &lt;label for="pending_checkbox"&gt;Pending&lt;/label&gt;
    &lt;/div&gt;
  
    &lt;div id="summary"&gt;
      &lt;p id="totals"&gt;&amp;nbsp;&lt;/p&gt;
      &lt;p id="duration"&gt;&amp;nbsp;&lt;/p&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  
  
  &lt;div class="results"&gt;
  &lt;div id="div_group_1" class="example_group passed"&gt;
    &lt;dl style="margin-left: 0px;"&gt;
    &lt;dt id="example_group_1" class="passed"&gt;Ark - Header (styles)&lt;/dt&gt;
    &lt;/dl&gt;
  &lt;/div&gt;
  &lt;div id="div_group_2" class="example_group passed"&gt;
    &lt;dl style="margin-left: 15px;"&gt;
    &lt;dt id="example_group_2" class="passed"&gt;that we have hit a valid URL&lt;/dt&gt;
      &lt;script type="text/javascript"&gt;moveProgressBar('14.2');&lt;/script&gt;
      &lt;dd class="example passed"&gt;&lt;span class="passed_spec_name"&gt;should not return an invalid error message&lt;/span&gt;&lt;span class='duration'&gt;7.76052s&lt;/span&gt;&lt;/dd&gt;
    &lt;/dl&gt;
  &lt;/div&gt;
  &lt;div id="div_group_3" class="example_group passed"&gt;
    &lt;dl style="margin-left: 15px;"&gt;
    &lt;dt id="example_group_3" class="passed"&gt;Ark Home Button&lt;/dt&gt;
      &lt;script type="text/javascript"&gt;moveProgressBar('28.5');&lt;/script&gt;
      &lt;dd class="example passed"&gt;&lt;span class="passed_spec_name"&gt;should exist&lt;/span&gt;&lt;span class='duration'&gt;2.22255s&lt;/span&gt;&lt;/dd&gt;
    &lt;/dl&gt;
  &lt;/div&gt;
  &lt;div id="div_group_4" class="example_group passed"&gt;
    &lt;dl style="margin-left: 15px;"&gt;
    &lt;dt id="example_group_4" class="passed"&gt;Ark Sign in link&lt;/dt&gt;
      &lt;script type="text/javascript"&gt;moveProgressBar('42.8');&lt;/script&gt;
      &lt;dd class="example passed"&gt;&lt;span class="passed_spec_name"&gt;should exist&lt;/span&gt;&lt;span class='duration'&gt;1.68413s&lt;/span&gt;&lt;/dd&gt;
    &lt;/dl&gt;
  &lt;/div&gt;
  &lt;div id="div_group_5" class="example_group passed"&gt;
    &lt;dl style="margin-left: 15px;"&gt;
    &lt;dt id="example_group_5" class="passed"&gt;Ark Home Button Style&lt;/dt&gt;
      &lt;script type="text/javascript"&gt;moveProgressBar('57.1');&lt;/script&gt;
      &lt;dd class="example passed"&gt;&lt;span class="passed_spec_name"&gt;should have accurate styling&lt;/span&gt;&lt;span class='duration'&gt;2.98297s&lt;/span&gt;&lt;/dd&gt;
    &lt;/dl&gt;
  &lt;/div&gt;
  &lt;div id="div_group_6" class="example_group passed"&gt;
    &lt;dl style="margin-left: 15px;"&gt;
    &lt;dt id="example_group_6" class="passed"&gt;Ark SignIn Button Style&lt;/dt&gt;
      &lt;script type="text/javascript"&gt;moveProgressBar('71.4');&lt;/script&gt;
      &lt;dd class="example passed"&gt;&lt;span class="passed_spec_name"&gt;should have accurate styling&lt;/span&gt;&lt;span class='duration'&gt;3.77360s&lt;/span&gt;&lt;/dd&gt;
    &lt;/dl&gt;
  &lt;/div&gt;
  &lt;div id="div_group_7" class="example_group passed"&gt;
    &lt;dl style="margin-left: 15px;"&gt;
    &lt;dt id="example_group_7" class="passed"&gt;Ark header Topbar Style&lt;/dt&gt;
      &lt;script type="text/javascript"&gt;moveProgressBar('85.7');&lt;/script&gt;
      &lt;dd class="example passed"&gt;&lt;span class="passed_spec_name"&gt;should have accurate styling&lt;/span&gt;&lt;span class='duration'&gt;2.78883s&lt;/span&gt;&lt;/dd&gt;
    &lt;/dl&gt;
  &lt;/div&gt;
  &lt;div id="div_group_8" class="example_group passed"&gt;
    &lt;dl style="margin-left: 15px;"&gt;
    &lt;dt id="example_group_8" class="passed"&gt;Post Sign-In Style&lt;/dt&gt;
      &lt;script type="text/javascript"&gt;moveProgressBar('100.0');&lt;/script&gt;
      &lt;dd class="example passed"&gt;&lt;span class="passed_spec_name"&gt;should have accurate styling&lt;/span&gt;&lt;span class='duration'&gt;17.62036s&lt;/span&gt;&lt;/dd&gt;
    &lt;/dl&gt;
  &lt;/div&gt;
  &lt;script type="text/javascript"&gt;document.getElementById('duration').innerHTML = "Finished in &lt;strong&gt;38.83569 seconds&lt;/strong&gt;";&lt;/script&gt;
  &lt;script type="text/javascript"&gt;document.getElementById('totals').innerHTML = "7 examples, 0 failures";&lt;/script&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>when I try the same command from the terminal in mac osx, it works without issue...</p>
  
  <p>This is the error I get when I try to run the command from within Ruby:</p>
  
  <pre><code>sed: 2: "/^&lt;div class="results"&gt; ...": undefined label 'ody&gt;/p'
  </code></pre>