#!/bin/awk -f # # center.awk # # center - center lines in file(s) or standard input # usage:center [filenames] # # For each line, a variable is created that holds the number of spaces # it wil take to center the current line. It then prints out the # spaces followed by the line. { spaces = "" for ( i = 1 ; i < (80 - length($0)) / 2; i++ ) spaces = spaces " " print spaces $0 }