2009/1/15 igor denisov <denisovigor1...@rambler.ru>:
> Hi there
> Can not understand.
>
> input:
> 34523 9348 98493 82983
> 9485 83928 9283 9283
> 394 39934 293 8347
> 3456 9238 9283 9283
>
> awk 'NR==1 { for (i = 1; i <= NF; i++) {n=$i; next}}; {n-=$i} END {print n}'
> input
>
> output:
> 21188 it is first column, why?

You should really take these questions to an awk forum, not to this
mailing list.

Your program reads the first record, and assigns its first column to
'n' in a loop that is immediately exited (with 'next') and goes on to
read the remaining records.

For the remaining records, 'i' being still 1 from the prematurely
exited loop, the first column is subtracted from 'n'.

Regards,
Andreas


-- 
Andreas Kahari
Somewhere in the general Cambridge area, UK

Reply via email to