On finished input (like a file) we can do that:
cat file | grep -o memory=[3-9] | sort -u
sort won't work with a stream:
tail -f server.log | grep -o memory=[3-9] | sort -u
server.log can be an infinite stream (a real time log). Above command can last hours.
how can I aggregate results adding another tool into the pipe,
or making somehow that
sort will work?
what is the alternative, instead of
grep, to have grepping there but also passing the argument into next step - next tool of the pipe.
I am not sure if pipe will allow that, at all.
maybe the second part of pipe must be a combined one (like something doing grep+sort at once)
I am only interested with the command-line approach to that.
It could be something like
watch, but updating the previous result.
On example: Instead of seeing a plenty of lines like:
memory=4 memory=4 memory=4 memory=4 memory=2 ...
I want to see just:
The above output is simplified, I wanted to highlight the aggregation of such output is my main problem.