title: Replacing one character in a multiple-lined pattern with Sed
body: <p>I have a file with a boolean value set for a file location that appears on the next line.  I need to change the 'delete' value to 1 for all filepaths that include 'trash' in them.  I am trying to use sed for this task.  </p>
  
  <p>I am having difficulty getting the pattern references (ie. \1 ) to output properly </p>
  
  <p>Please see the file sample below:</p>
  
  <pre><code>delete: 0
  filepath: Downloads/trash/foo1
  delete: 0
  filepath: Downloads/keep/foobar
  delete: 0
  filepath: Downloads/trash/foofoofoo
  </code></pre>
  
  <p>This is what I have for sed function.  I am trying to catch the second line to be reference by \1 later but it outputs as just '1'.  </p>
  
  <pre><code>sed -e '
  /delete)/{
  N
  /\(.*trash.*\)/c \
  delete: 1
  \1
  }' test.txt &gt; test2.txt
  </code></pre>
  
  <p>The output:</p>
  
  <pre><code>delete: 1
  1
  delete: 0
  filepath: Downloads/keep/foo1
  delete: 1
  2
  </code></pre>
  
  <p>I see changes in both the lines I want, so I know I'm fetching the correct lines in pattern space.  But the second line is not outputting properly. I also know this type of syntax works fine in single-line replacements, but not in this multi-line situation. </p>
  
  <p>Any help would be appreciated.  Thank you. </p>