agroup: build the groups of key-value pairs, grouped by the keys Usage: agroup -key {expr} -val {expr} [other params] Parameters: -key {expr}: specify the expression that calculates the group key -val {expr}: the previous for the values -f {file}: specify an input file (instead of the standrad input) -sep {separator}: specify the separator for the results (between group names, values, aggregate results) -s: single line printing of the grouped values -v {vardef}: define a runtime variable -a {expr}: specify an aggregate expression (this is evaluated for each group item) -ar {expr}: specify the aggregate result for the groups (evaluated only once for each group, respectively) Runtime variables: line: contains the current input line value: contains the value (specified by the -val parameter) of a given record. This value is used to calculate the aggregate results. Examples: Let the test file contain the following lines: apple|10 apple|20 banana|10 apple|40 grape|10 banana|20 apple|50 acat test.txt | agroup -key "strtok(line, '|', 0)" -val "strtok(line, '|', 1)" -> the groups are based on the first token of the lines (this the key: the name of the group), the values are the second tokens of the lines apple|10 apple|20 apple|40 apple|50 banana|10 banana|20 grape|10 ... | agroup -key "strtok(line, '|', 0)" -val "strtok(line, '|', 1)" -s -> the groups take only one line: each line starts with the group name, then it is followed by the values that are assigned to it, separated by the (now default) separator ('|') apple|10|20|40|50 banana|10|20 grape|10 ... | agroup -key ... -val ... -v "sum" -a "sum += #value" -ar "sum" -> calculate the (aggregated) sum value of the groups apple|120 banana|30 grape|10 ... | agroup -key ... -val ... -v "sum" -a "sum += #value" -ar "sum" -v "min=1000" -a "aif(#value < min, min, #value)" -ar "min" -s -> calculate the sum and minimum aggregate values for the groups apple|120|10 banana|30|10 grape|10|10