#!/usr/bin/gawk -f #/* vim: set filteype=awk : */ -*- awk -*- BEGIN{ IGNORECASE=1; TopTreatments=1; #The number of top treatments to select CurrentTreatment=1; CurrentSearch=CurrentTreatment " worth"; Attrs=""; srand(); } { if(match($0, CurrentSearch) > 0) { CurrentTreatment++; sub(/.*\t/, "[", $0) sub(/\[+/, "[", $0) sub(/[ \t]*$/, "", $0) gsub(/ +/, ",", $0) # out=gensub(/=.*\]/,",", "G", $0) # print out # print $0 split($0, parts, ",") for (j in parts) { sub(/\=.*\]/, "", parts[j]) sub(/\[/, "", parts[j]) # print parts[j] if(Attrs=="") { Attrs=parts[j] } else { Attrs=Attrs "," parts[j] } } if(CurrentTreatment > TopTreatment) { exit; } else { CurrentSearch=CurrentTreatment " worth"; } } else { next; } } END{ #Attrs=gensub(/ +/, "", "g", Attrs) print Attrs; }