title: Find Longest Line in a .txt File and fill all Lines to that Length with 'blank Spaces'?
body: <p>How can I find the longest line in a .txt file and then fill all other lines at their end to that length with blank spaces?</p>
  
  <p>My guess is this is easy to answer. I know very little about using the awk, paste command
  and such. Maybe someone can help me out. Thanks!</p>
  
  <p>A little more specific... so far I can do the following. This would get the longest Line from a .txt File:</p>
  
  <pre><code>awk '{ if (length($0) &gt; max) {max = length($0); maxline = $0} } END { print maxline }' in.txt
  </code></pre>
  
  <p>This fills the lines with blank spaces (till 50):</p>
  
  <pre><code>awk  'length &lt;= 50 { printf "%-50s\n",$0 }' in.txt &gt; out.txt
  </code></pre>
  
  <p>I just don't know to pass the value from one line to the other.</p>
  
  <p>Why am I asking this? I want to merge two .txt files using the paste command. Text B will be positioned to the right of Text A. Lines in Text A will have different lengths. So if there are not enough blank spaces the layout isn't right. </p>