#!/usr/bin/awk # input1: the input data # input2: the rule to be applied for erasing some values # input 3: the maximal index for an item # out: the data with missing values BEGIN{ if (ARGC != 4){ print "error usage: " ARGV[0] " "; exit(1); } rule = ARGV[2]; missingItem = ARGV[3] + 1; ARGC -= 2; getline line < rule; # decode a line such as 37 , 7 : 14 = 7 32 45 49 51 65 66 85 141 187 226 230 247 269 split(line, tab1, " = "); split(tab1[1], tab2, " , "); split(tab2[2], tab3, " : "); # list of impacted values noValues = split(tab3[1], tabvalues, " "); for (i = 1; i <= noValues; i ++) values[tabvalues[i]] = 1; # load the list of lines noLines = split(tab1[2], tablines, " "); for (i = 1; i <= noLines; i ++) lines[tablines[i]] = 1; } { printf("%d", $1); for (i = 2; i <= NF; i ++){ if ((NR in lines) && ($i in values)) printf(" %d", missingItem); else printf(" %d", $i); } printf("\n"); }