I have the following awk statement which I am trying to modify so that if $5 does not contain an A-Z (middle initial), field 5 will be null rather than containing the next field, the date.
awk 'BEGIN{printf ("%-7s %-15s %-15s %-3s %-10s %-6s %-6s %-4s\n", "Emp #", "Last", "First", "MI", "Start Date", "Dept", "ETR", "TS"}
{if ($1 ~ "[0-9]{5}" && $2 !~ "[a-z]{3}" && $0 !~ "ETR31"
printf ("%-7s %-15s %-15s %-3s %-10s %-6s %-6s %-4s\n", $1, $2, $3, $4, $5, $6,$7, $8)}' newhires.list > newhires.rpt
I tried adding something like: " ; if ($5 !~ "[A-Z]$" $5 = "")" to the if statement, but that does not work properly. Any help would be greatly appreciated.
Thanks,
John
awk 'BEGIN{printf ("%-7s %-15s %-15s %-3s %-10s %-6s %-6s %-4s\n", "Emp #", "Last", "First", "MI", "Start Date", "Dept", "ETR", "TS"}
{if ($1 ~ "[0-9]{5}" && $2 !~ "[a-z]{3}" && $0 !~ "ETR31"
printf ("%-7s %-15s %-15s %-3s %-10s %-6s %-6s %-4s\n", $1, $2, $3, $4, $5, $6,$7, $8)}' newhires.list > newhires.rpt
I tried adding something like: " ; if ($5 !~ "[A-Z]$" $5 = "")" to the if statement, but that does not work properly. Any help would be greatly appreciated.
Thanks,
John