nawk -f char.awk fileFROMscript fileWithAllAccounts
char.awk:
Code:
# for the FIRST file specified on the command line....
# build array 'arr' indexed by the values from the SECOND column AND
# the accumulated values from the FIRST column.
FNR==NR {arr[$2] += $1; next }
# for the SECOND file specified on the command line......
# print every record.
# if the value of the FIRST column appears as the INDEX in 'arr' - print the
# 'value' from 'arr'. Otherwise print '0' .
{
printf("%d%s%s\n", ($1 in arr) ? arr[$1] : 0, OFS, $1)
}