title: Find and concatenate lines using sed
body: <p>I have a struct blocks within a long c file</p>
  
  <pre><code>struct node {
     int val;
     struct node *next;
  };
  </code></pre>
  
  <p>How do I use the sed function to find this struct block and convert it into one line. So it looks like this:</p>
  
  <pre><code>struct node {   int val;   struct node *next;};
  </code></pre>
  
  <p>Thanks in advance</p>
  
  <hr>
  
  <p>My input is this:</p>
  
  <pre><code>struct node {
     int val;
     struct node *next;
  };
  
  typedef struct {
     int numer;
     int denom;
  } Rational;
  
  int main()
  {
  struct node head;
  Rational half, *newf = malloc(sizeof(Rational));
  
  head = (struct node){ 5, NULL };
  half = (Rational){ 1, 2 };
  *newf = (Rational){ 2, 3 };
  }
  </code></pre>
  
  <p>My output is :</p>
  
  <pre><code>struct node { int val; struct node *next;};
  
  typedef struct { int numer; int denom;} Rational;int main(){struct node head;Rational  half, *newf = malloc(sizeof(Rational));head = (struct node){ 5, NULL };
  half = (Rational){ 1, 2 };
  *newf = (Rational){ 2, 3 };
  }
  </code></pre>
  
  <p>I only want the struct node: <code>struct node { int val; struct node *next;};</code><br>
  and the typedef struct: <code>typedef struct { int numer; int denom;} Rational;</code>
  to be in one line. However int main() is being appended to the end of Rational;</p>
  
  <p>I want the stuff in the main function to remain as it is.</p>