Is there an easy way to align text to the center with padding on both sides, with the column width being the longest line from the input?For example, this:aaabbbbcdddddeewill turn into this (the dots represent spaces):.aaa.bbbb...c..ddddd.ee..Any tool is fine. Be it sed or awk or a bunch of coreutils tools.Edit: I think some of you misunderstood the output. The output is padded with spaces, not dots. I've used dots here just to make it more clear.
Align text to center with padding on both sides
shell script;text processing;awk
Here's my solution, as posted in my comment to Thor's answer:awk -v M=`wc -L file` '{ printf %*s%*s, (M+length)/2, $0, (M-length+1)/2+1, \n }' < fileI feel it solves the problem elegantly and succinctly, and therefore I'm reposting it as an answer.