title: sed right align a group of text
body: <p>this question originated from <a href="https://stackoverflow.com/questions/19587314/string-pattaren-matching-using-awk">string pattaren-matching using awk</a> , basically we are splitting a line of text in multiple groups based on a regex pattern, and then printing two groups only. Now the question is can we right align a group while printing through <code>sed</code>?
  below is an example</p>
  
  <pre><code>$cat input.txt
  it is line one
  it is longggggggg one
  itttttttttt is another one
  </code></pre>
  
  <p>now</p>
  
  <pre><code>$sed -e 's/\(.*\) \(.*\) \(.*\) \(.*\)/\1 \3/g' input.txt
  </code></pre>
  
  <p>it splits and prints group 1 and 3, but the output is </p>
  
  <pre><code>it line
  it longggggggg
  itttttttttt another
  </code></pre>
  
  <p>my question is can we do it through <code>sed</code> so that the output comes as </p>
  
  <pre><code>it                             line
  it                      longggggggg
  itttttttttt                 another
  </code></pre>
  
  <p>I did it with <code>awk</code> but I feel it can be done through <code>sed</code>, but I am not able to get how I am going to get the length of the second group and then pad correct number of spaces in between the groups, I am open to any suggestions to try out.</p>