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?
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!
A little more specific... so far I can do the following. This would get the longest Line from a .txt File:
awk '{ if (length($0) > max) {max = length($0); maxline = $0} } END { print maxline }' in.txt
This fills the lines with blank spaces (till 50):
awk 'length <= 50 { printf "%-50s\n",$0 }' in.txt > out.txt
I just don't know to pass the value from one line to the other.
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.