title: SED: Combine text between two pattern in same line
body: <p>I m trying to use sed /awk command to parse my text file.
  I want to print text between two pattern in same line with some character added in it.
  ex: 
  If my line is </p>
  
  <p><code>uint8_t aucRepresentationName[NR_UNIT_REPRESENTATIONS][CHARS_P_REPRESENTATION];</code></p>
  
  <p>OR</p>
  
  <pre><code>uint8_t aucRepresentationName [NR_UNIT_REPRESENTATIONS] [CHARS_P_REPRESENTATION];
  </code></pre>
  
  <p>I want to print <code>NR_UNIT_REPRESENTATIONS*CHARS_P_REPRESENTATION</code></p>
  
  <p>So , I have stared with sed command to insert line deliminter <code>\n</code> after <code>'['</code> , deviding line in suitable species and then tried to parse it again.</p>
  
  <pre><code>echo "bla bla bla [AK] bla bla bla bla [A_K] bla bla bla" | sed 's/\[/\n&amp;/g;' | awk '{sub(/.*\[ /,"");sub(/\].*/,"");print;}'
  
  echo "bla bla bla [AK] bla bla bla bla [A_K] bla bla bla" | sed 's/\[/\n&amp;/g;' | sed -e 's/^.*\[ //g;s/ \].*$//g'
  </code></pre>
  
  <p>And  it is not always two diamensional array, it could be none  or single/double dimentional array, I need to first how many instance of [], if its 0 then write 1, if its single diamensional array then ex A[SIZE] then write SIZE its two diamensional array ex:A[RAW][COL] write RAW*COL.. </p>
  
  <p>I would like to know what is wrong in my command? or any other option to do it as it will help me to further study sed.</p>
  
  <p>Amruta</p>