title: using sed to change <CR><LF> to a symbol
body: <p>Am working on Windows Vista with GnuWin32 (sed 4.2.1 and core utilities 5.3.0). Also have ActivePerl 5.14.2 package.</p>
  
  <p>I have a large multi record file. The end of each record in the file is denoted with four dollar signs ($$$$). Within each logical record are many "CRLF."</p>
  
  <p>I would like to replace all instances of CRLF with a symbol such as <code>|+|</code>. Then I will replace <code>$$$$</code> with CRLF. The result: one record per row for import into Excel for further manipulation.</p>
  
  <p>I've tried several methods for transforming <code>CRLF</code> to <code>|+|</code> but without success.</p>
  
  <p>For example, one method was: <code>sed -e "s/[\r\n]/|+|/g" source_file_in target_file_out</code></p>
  
  <p>Another method used <code>tr -d</code> to delete <code>\r</code> and then a second statement: <code>sed -e "s/\n/|+|/g" source_file_in target_file_out</code></p>
  
  <p>The <code>tr</code> statement worked; the <code>sed</code> statement did not.</p>
  
  <p>I've read the following articles but don't see how to adapt them to replace <code>\r\n</code> with a symbol like <code>|+|</code>.</p>
  
  <p><a href="https://stackoverflow.com/questions/5422162/sed-how-to-replace-cr-and-or-lf-with-r-n-so-any-file-will-be-in-one-line">sed: how to replace CR and/or LF with &quot;\r&quot; &quot;\n&quot;, so any file will be in one line</a></p>
  
  <p><a href="https://stackoverflow.com/questions/11393616/replace-string-that-contains-crlf/11393990#11393990">Replace string that contains CRLF?</a></p>
  
  <p><a href="https://stackoverflow.com/questions/1251999/sed-how-can-i-replace-a-newline-n">How can I replace a newline (\n) using sed?</a></p>
  
  <p>If this problem cannot be solved easily using <code>sed</code> (and <code>tr</code>), then I'll use Perl if someone shows me how.</p>
  
  <hr>
  
  <p>Thank you Ed for your recommendation.</p>
  
  <p>The awk script is not yet working completely, so I'll add some missing detail with the hope that you can fine tune your recommendation.</p>
  
  <p>First, I'm running gawk v3.1.6.2962. I believe there may be differences in awk implementations, so this may be a useful bit of information.</p>
  
  <p>Next, some more information about the type of data and origin of the data.</p>
  
  <p>The data is about chemicals (text data that is input to a stereo-chemical drawing program).</p>
  
  <p>The chemical files are in an .sdf format.</p>
  
  <p>When I open "133711.sdf" in NotePad++ (using View/Show symbol/Show all characters), I see data that is shown in the screen shot:
      <a href="https://dl.dropbox.com/u/3094317/_master_1_screen_shot_.png" rel="nofollow noreferrer">https://dl.dropbox.com/u/3094317/_master_1_screen_shot_.png</a></p>
  
  <p>As you see, LF only - no CR.
  I believe this means that the origin of the .sdf files is a UNIX system.</p>
  
  <p>Next, I run the Windows command COPY *.sdf _master_2_.txt. That creates the very large file-of-files that I want to parse into records.</p>
  
  <p>_master_2_.txt has the same structure as 133711.sdf - LF only; no CR.</p>
  
  <p>Then, I run your awk recommendation in a .BAT file. I need to replace your single quotes with double quotes because Microsoft made me.</p>
  
  <p>awk -v FS="\r\n" -v OFS="|+|" -v RS="\$\$\$\$" -v ORS="\r\n" "{$1=$1}1" C:_master_2_.txt >C:\output.txt</p>
  
  <p>I've attached a screen shout of output.txt:
      <a href="https://dl.dropbox.com/u/3094317/output.txt.png" rel="nofollow noreferrer">https://dl.dropbox.com/u/3094317/output.txt.png</a></p>
  
  <p>As you can see, the awk command did not successfully replace "\r\n" with "|+|".</p>
  
  <p>Further, Windows created the output.txt with CRLF.</p>
  
  <p>It did successfully replace the four $ with CRLF.</p>
  
  <p>Is this information adequate to update your awk recommendation to handle the Windows-related issues?</p>