The uniq(1)
command can be viewed as a tiny map/reduce-style program:
- map consecutive, identical input lines into groups;
- reduce the list of lines (which are all identical) to a single line.
Are there more examples of programs in this (functional) style in Unix? And, if I would like to use another map or reduce function, are there more generic tools out there that let one provide custom mappers and reducers?
Maybe something like this:
mapreducer -mapper prog1 -reducer prog2 < input > output