0

On finished input (like a file) we can do that:

cat file | grep -o memory=[3-9] | sort -u

But 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?

OR:

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:

memory=4
memory=2

The above output is simplified, I wanted to highlight the aggregation of such output is my main problem.

0

1 Answer 1

0

the working solution is:

$ tail -f infinite_server.log | grep -o memory=[3-9] > output &

then

$ watch "cat output | sort -u"
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .