# Set padding character to the default (" ") if it was not set with -v # Set ORS to "" to make printing easier #FNR == NR { if(length > M) M = length; next } BEGIN { if(D == "") D = " "; ORS = "" } # Pad each line according current line length (L) and longest line (M) { L = wcL - length; for(i=1; i<=int(L/2); i++) print D print $0 for(i=1; i<=int(L/2+.5); i++) print D print "\n" }