#!/bin/sh
gawk -F, '
BEGIN { printf("age workclass education marital-status occupation relationship race sex hours-per-week native-country salary\n"); }
{ if      ($1  <= 25) printf("young");
  else if ($1  <= 45) printf("middle-aged");
  else if ($1  <= 65) printf("senior");
  else                printf("old");
  printf("%s%s%s%s%s%s%s ", $2, $4, $6, $7, $8, $9, $10);
  if      ($13 <  25) printf("half-time");
  else if ($13 <= 40) printf("full-time");
  else if ($13 <= 60) printf("over-time");
  else                printf("too-much");
  printf("%s ", $14);
  if (($15 == " <=50K") || ($15 == " <=50K.")) printf("<=50K\n");
  else                                         printf(">50K\n");
}' $1.data > $1.tab
