title: Bash/sed: Concat multiple line plus eat up leading spaces for sublines
body: <p>I want to parse Makefiles containing lines like these:</p>
  
  <pre><code>FILES=file1.c \
        file2.c \
        file3.c \
  </code></pre>
  
  <p>Now I want to parse that beast to get a result like this:</p>
  
  <pre><code>FILES=file1.c file2.c file3.c
  </code></pre>
  
  <p>Means it should concat all line to one line and eat up the leading spaces.
  I already managed to concat the lines by using this sed call:</p>
  
  <pre><code>sed -e ':loop;/\\$/N;s/\\\n/ /;t loop'
  </code></pre>
  
  <p>which results in</p>
  
  <pre><code>FILES=file1.c      file2.c      file3.c
  </code></pre>
  
  <p>But yet did not manage to also eat up the leading spaces for line 2 and line 3 of my example.</p>
  
  <p>Thanks for any help,</p>
  
  <p>Roland</p>
  
  <p>BTW: I am using GNU sed version 4.1.5 here. </p>