Using variables to count sums
Let’s now tackle something more involved: counting the number of times someone ordered a chicken bowl.
To do so, we’ll use awk’s BEGIN and END statements, which let you run some code once before processing your file (BEGIN), and once after all rows in the file have been processed (END):
Let’s break this down:
sum to 0Chicken Bowl, we increment sum by the number of bowls orderedsum