Re: Need a quick one-liner
In article <[🔎] 20030704124928.GC713@localhost>,
Seneca <seneca-cunningham@rogers.com> wrote:
>On Fri, Jul 04, 2003 at 01:51:34PM +0200, Joerg Johannes wrote:
>> I have some data files in the following format:
>>
>> 1 2 3 4
>> 5 6 7 8
>> 9 10 11 12
>> 13 14 15 16
>> ...
>>
>> I need to sum up the second column, so the result is 32 (in this case).
>> Any ideas?
>
>awk '{ sum += $2 ; print sum }' foo | tail -1
Isn't that
awk '{ sum += $2; } END { print sum }' foo
? Awk rocks ;)
Mike.
Reply to: