title: Using sed to remove new line characters from the middle of a field
body: <p>the data i have looks something like this</p>
  
  <pre><code>a,b,c,d
  a,b1
  b2,c,d
  A,B,C,D
  </code></pre>
  
  <p>What is happening is that in field 2 there is occasionally a new line character in the second field so the line gets split over two lines</p>
  
  <p>So far i have found a sed script that will do this it reads like </p>
  
  <pre><code>cat file| sed ':a;N;$!ba;s/\(\(b1\)\)\n/\1/g'
  </code></pre>
  
  <p>but i am struggling to get the correct combinations of (.*,) to make this work so i've substituted it with b1 to get this example to work but in the real world A, B, C and D are field of mixed length and content</p>
  
  <p>The end result i'm looking for is this</p>
  
  <pre><code>a,b,c,d
  a,b1b2,c,d
  A.B,C,D
  </code></pre>
  
  <p>Any help is much appreciated</p>
  
  <p>Thanks
  Matt</p>