title: removing new line character from incoming stream using sed
body: <p>I am new to shell scripting and i am trying to remove new line character from each line using SED. this is what i have done so far :</p>
  
  <pre><code>printf "{new\nto\nlinux}" | sed ':a;N;s/\n/ /g'
  </code></pre>
  
  <p>removes only Ist new line character.
  I somewhere found this command :</p>
  
  <pre><code>printf "{new\nto\nlinux}" | sed ':a;N;$!ba;s/\n/ /g'
  </code></pre>
  
  <p>but it gives :"ba: Event not found."</p>
  
  <p>if i do:</p>
  
  <pre><code>printf "{new\nto\nlinux}" | sed ':a;N;s/\n/ /g' | sed ':a;N;s/\n/ /g'
  </code></pre>
  
  <p>then it gives correct output but i am looking for something better as i am not sure how many new character i will get when i run the script.
  incoming stream is from echo or printf or some variable in script.
  Thanks in advance</p>