title: In bash, replace newline in csv files, except when at line's end
body: <p>I have a huge csv file, about 500Mb. The field separator is the pipe char (|). Some lines contain newlines and carriage returns. I need to remove them, but I don't want to remove the legitimate newlines at the end of each lines. I have tried with sed and tr as shown in other questions but I end up removing all newlines, which is not what I want. </p>
  
  <p>Sample input (the ||Yes line should be joined to the previous line):</p>
  
  <pre><code>21/06/2016 18:06:32|||||||||||||||||||32 Red|Jrup Vej 6|61069849
  ||Yes||vals
  21/06/2016 18:06:32|||||||||||||||||||101 K|Ser Bevard 110|||No|
  </code></pre>
  
  <p>My attempts:</p>
  
  <pre><code>sed -i 's/\r\n//g' myfile.csv
  
  tr -d '\r' &lt; myfile.csv
  </code></pre>
  
  <p>Thanks for any help,
  Joe</p>