I'm attempting to decipher the action in the following awk
statement specifically what the ;
after the first user defined variable refers to.
{ num_gold++; wt_gold += $2 }
In awk
, you can write two statements in one line separated by ;
(semi-colon)
{ num_gold++; wt_gold += $2 }
Otherwize, you should put them into separated lines:
{
num_gold++
wt_gold += $2
}
To print the variables, you just add print
before the variables:
{
num_gold++
wt_gold += $2
print num_gold
print wt_gold
}
As I said, you can put them all in one line:
{ num_gold++; wt_gold += $2; print num_gold; print wt_gold; }
It's too long!
print
also accepts multiple arguments, so try print num_gold, wt_gold
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With