#!/usr/bin/awk # input1: column dictionary # input2: value of the maximum item on the input data # param1: the number of items # output: for each line, changes the '?' value with the corresponding item BEGIN{ if (ARGC != 4){ print "error usage: " ARGV[0] " "; exit(1); } item = ARGV[3] + 1; colDictionary = ARGV[2]; ARGC -= 2; while ((getline line < colDictionary) > 0){ if (length(line)){ codes[line] = item; item ++; } } } { printf("%d", $1); for (i = 2; i <= NF; i ++){ if ($i == "?") printf(" %d", codes[i]); else printf(" %d", $i); } printf("\n"); }