Listing 3. Mailing Label Generation

#!/bin/sh

addcol Line1 Line2 Line3 Line4 |
compute 'if(Salut ne "")
           Line1 = sprintf("%s %s %s",Salut,Fname,Lname);
         else
           Line1 = sprintf("%s %s",Fname,Lname);
         CityStateZip = sprintf("%s %s %s",\
         City,State,Zip);
         Line2 = Address1;
         if (Address2 == "")
           Line3 = CityStateZip;
         else
           Line3 = Address2;
         if (Address2 == "")
           Line4 = "";
         else
           Line4 = CityStateZip;' |
sorttable Zip |
report mailing.frm | pr -2 -t -l 60 -o 4 -w 80