68user's page 掲示板

Prev< No. 4285> Next  [最新発言に戻る] [過去ログ一覧]
No. 4285 # シャチ 2005/09/10 (土) 10:00:34
>>4280 くま
以下ので出来ると思います。

----------------------------------
#!/bin/sh

nawk -F"," '
        BEGIN {
        }
function syukei() {
        total=0+0;
        no=$1;

        while (NF>0) {
                if (no == $1) {
                        total = total + $2;
                } else {
                        printf("%03d:%d\n",no,total);
                        no=$1;
                        total=$2;
                }
                getline;
        }
        printf("%03d:%d\n",no,total);
}
{
        if (NF == 0) next ;
        syukei() ;
}' file.txt

exit 0

Prev< No. 4285> Next  [最新発言に戻る] [過去ログ一覧]