#!/usr/bin/gawk -f #/* vim: set filteype=awk : */ -*- awk -*- BEGIN{ Results=ENVIRON["allTreatments"] Runs=ENVIRON["runs"] Selected="" gsub(/ +/, " ", Results) split(Results, Attrs, ",") # print "The Previous results were: " Results for(I in Attrs) { # print Attrs[I] Occurrences[Attrs[I]]++ } for(J in Occurrences) { if(Occurrences[J] >=(Runs/2)) #(2*(Runs/3)))#(Runs/2)) { # print J " occurred " Occurrences[J] " times, enough to be added" Selected=J " " Selected } else { # print J " occurred " Occurrence[J] " times, not often enough" } } print Selected }