miller/docs/data/maxrows.mlr
2020-09-27 11:29:50 -04:00

15 lines
323 B
Text

# Retain all records
@records[NR] = $*;
# Track max value of n
@maxn = max(@maxn, $n);
# After all records have been read, loop through retained records
# and print those with the max n value.
end {
for (int nr in @records) {
map record = @records[nr];
if (record["n"] == @maxn) {
emit record;
}
}
}