Hi,

  I think you're missing the fact that the subtruct variable is not
initialized and defaults to 0.
  So, what you get is

0 - 34523 - 9485 - 394 - 3456 = -47858

  not

34523 - 9485 - 394 - 3456 = 21188

  Cheers,

    Daniele


igor denisov wrote:
> Hello there.
>
> There is a problem here.
>
> input:
>  34523
>  9485
>  394
>  3456
>
> awk '{subtruct-=$1} END {print subtruct}' input
>
> output:
> -47858
> same thing but without minus with
>
> awk '{sum+=$1} END {print sum}' input
>
> output:
> 47858
>
> Why in both cases the code sums the field?
> -- 
> igor denisov.

Reply via email to