#! /bin/bash Coc81="coc81_all coc81_kind_min coc81_lang_ftn coc81_mode_e coc81_kind_max coc81_mode_org coc81_lang_mol" Nasa93="nasa93_all nasa93_project_gro nasa93_cat2_missionplanning nasa93_cat2_avionicsmonitoring nasa93_mode_semidetached nasa93_project_sts nasa93_forg_g nasa93_center_5 nasa93_year_1975 nasa93_year_1980 nasa93_mode_embedded nasa93_center_2" All="coc81_all nasa93_all coc81_kind_min coc81_lang_ftn coc81_mode_e coc81_kind_max coc81_mode_org coc81_lang_mol nasa93_project_gro nasa93_cat2_missionplanning nasa93_cat2_avionicsmonitoring nasa93_mode_semidetached nasa93_project_sts nasa93_forg_g nasa93_center_5 nasa93_year_1975 nasa93_year_1980 nasa93_mode_embedded nasa93_center_2" { for File in $Coc81 do Filename=$File"_Ranks.txt" gawk 'NR>1{print $0}' $Filename done } | gawk 'BEGIN{FS=OFS=","; print "key,ties,wins,losses,wins-losses"} { Ties[$1]+=$2; Wins[$1]+=$3; Losses[$1]+=$4;} END { j=1 for (x in Ties) { tmp[j]=x j++ } n=asort(tmp) for (i=1;i<=n;i++) { print tmp[i], Ties[tmp[i]], Wins[tmp[i]], Losses[tmp[i]], Wins[tmp[i]]-Losses[tmp[i]] } }' > coc81_aggregate.txt { for File in $Nasa93 do Filename=$File"_Ranks.txt" gawk 'NR>1{print $0}' $Filename done } | gawk 'BEGIN{FS=OFS=","; print "key,ties,wins,losses,wins-losses"} { Ties[$1]+=$2; Wins[$1]+=$3; Losses[$1]+=$4;} END { j=1 for (x in Ties) { tmp[j]=x j++ } n=asort(tmp) for (i=1;i<=n;i++) { print tmp[i], Ties[tmp[i]], Wins[tmp[i]], Losses[tmp[i]], Wins[tmp[i]]-Losses[tmp[i]] } }' > nasa93_aggregate.txt { for File in $All do Filename=$File"_Ranks.txt" gawk 'NR>1{print $0}' $Filename done } | gawk 'BEGIN{FS=OFS=","; print "key,ties,wins,losses,wins-losses"} { Ties[$1]+=$2; Wins[$1]+=$3; Losses[$1]+=$4;} END { j=1 for (x in Ties) { tmp[j]=x j++ } n=asort(tmp) for (i=1;i<=n;i++) { print tmp[i], Ties[tmp[i]], Wins[tmp[i]], Losses[tmp[i]], Wins[tmp[i]]-Losses[tmp[i]] } }' > all_aggregate.txt