LJ Archive

Listing 1. AWK Script

#!/usr/bin/awk -f
#centre: centre lines in file(s) or stdin
#usage: centre [filenames]
BEGIN {
 linelength = 80
 spaces = ""
}
{
 for (i = 1; i < (linelength - length($0)) / 2; i++)
 spaces = spaces " "
 print spaces $0
}
LJ Archive