35.8 Centering Lines in a File
Here's an
awk
script, written by Greg Ubben,
that centers lines across an 80-character line.
If your system understands
#!/usr/bin/awk -f { printf "%" int(40+length($0)/2) "s\n", $0 }
For each input line, the script builds a
printf
command
with a width specification (like In vi , you can use a filter-through ( 30.22 ) command to center lines while you're editing. Or just use center from the command line. For example:
% - |
|