home *** CD-ROM | disk | FTP | other *** search
- #!/bin/sh
- #
- # pphone.fmt - format the pphone database into a nice troff-able
- # phone list of the format
- #
- # Name in bold face
- # Home Address Work Address
- # Home Phone Work Phone
- # Electronic Mail Address
- #
-
- #
- # Put out troff header (set point size, etc.)
- #
- cat << EOF
- .\"
- .\" Run me off with "troff -ms"
- .\"
- .nr LL 6.5i
- .nr PO 1i
- .nr PS 12
- .nr VS 14
- .ll 6.5i
- .po 1i
- .ps 12
- .vs 14
- .nf
- EOF
-
- #
- # Let awk handle reformatting. Basically, we want to print out, for
- # each entry:
- #
- # .ne 6v <-- makes sure whole entry fits on page
- # .B "Name"
- # .mk
- # .in .5i
- # Home Address
- # Home Phone
- # .rt
- # .in 3i
- # Work Address
- # Work Phone
- # Electronic Address
- # .sp
- #
- # We have special stuff to handle blank lines in the home and/or work
- # address, and then at the end we have to put in some blank lines to
- # make sure the work address is at least as long as the home address,
- # since we're using marks/returns.
- #
- awk 'BEGIN { FS = "\t" }
- { if (NR > 1) {
- home = ""
- homen = 0
- for (i=2; i <= 4; i++) {
- if (length($i) > 0) {
- home = home $i "\n"
- homen++
- }
- }
-
- work = ""
- workn = 0
- for (i=5; i <= 9; i++) {
- if (length($i) > 0) {
- work = work $i "\n"
- workn++
- }
- }
-
- printf ".ne 6v\n.B \"%s\"\n", $1
- printf ".in .5i\n.mk\n"
- printf "%s", home
- printf ".rt\n.in 3i\n"
- printf "%s", work
-
- while (homen > workn) {
- printf "\n"
- homen--
- }
-
- printf ".sp\n.in 0\n"
- }
- }'
-