In awk
you can write two statements on the same line, separated by a character ;
(semi-colon)
{ num_gold++; wt_gold += $2 }
Otherwise, you should put them on separate lines:
{ num_gold++ wt_gold += $2 }
To print variables, simply add print
before the variables:
{ num_gold++ wt_gold += $2 print num_gold print wt_gold }
As I said, you can put them all on one line:
{ num_gold++; wt_gold += $2; print num_gold; print wt_gold; }
Too long!
print
also takes several arguments, so try print num_gold, wt_gold
.
source share