Kシェル上でフラットファイルの条件付き集計をしたい。
いつもお世話になっています。Kornシェルで、以下のようなcsv形式のファイルを次の様に集計したいです。
<列A,C,D,E,F,G が全て一致する行毎に列Fの値を集計>
(入力)
列A------列B------列C----列D---列E--列F-----列G------列F
"10001","0090300", 11110," "," "," "," ",1013134
"10001","0090300", 11130,"0009","888","01","5050455",28428260
"10001","0090300", 11130,"0001","001","01","1111111",258925
"10001","0090300", 11165,"9900","999","09","9999903",0
"10001","0090300", 11110," "," "," "," ",592092
"10001","0090400", 11130,"0009","129","01","1018224",12489867
"10001","0090300", 11130,"0001","001","01","1111111",200000
"10001","0090400", 11165,"9900","999","09","9999904",834592
"10001","0090700", 11110," "," "," "," ",300000
(期待する出力)
"10001","0090300", 11110," "," "," "," ",1905226 <--- 1行目, 5行目, 9行目が集計されている
"10001","0090300", 11130,"0009","888","01","5050455",28428260
"10001","0090300", 11130,"0001","001","01","1111111",458925 <--- 3行目と7行目が集計されている
"10001","0090300", 11165,"9900","999","09","9999903",0
"10001","0090400", 11165,"9900","999","09","9999904",834592
"10001","0090400", 11130,"0009","129","01","1018224",12489867
出力のソートの必要はありません。
これをシェル・スクリプトだけで実装するのは、無理でしょうか。良いアイディアをお願いします。
お礼
しおたん99さん、ありがとうございます☆ おかげ様で思い通りに出来ましたぁ~~!!!! これで銀行から引き出したり預けたりが分かるし、 残高も一目瞭然だし、とても便利になりました♪ もっと早くお礼したかったのですが( こんなにも 分かり易く説明してくださっているにも係わらず!) 微妙に てこずってて遅くなっちゃいました^^; 理解できれば一気に「あー」ってなるんですけどね。 「あー」ってなるまでが大変ですよね( 意味不明 ) こんなに長い式になるとはビックリでした。 しおたん99さんは凄いです。 本当に、どうもありがとうございました☆ また機会があったら、お願いしますm(_ _)m