I have the need to match the first two columns and when they match, calculate the percent of average for the third columns. The following awk script does not give me the expected results.
awk 'NR==FNR {T[$1,$2]=$3; next} $1,$2 in T {P=T[$1,$2]/$3*100; printf "%s %s %.0f\n", $1, $2, (P>=0)?P:-P}' diff.file avg.file > output.file
percent of average = diff/avg * 100
Ill need to ignore/remove the minus/negative symbols if any in the output file.
Diff File
46.0625 -99.1042 11.6
Avg File
46.0625 -99.1042 12.3
expected output
46.0625 -99.1042 206
Any suggestions?