Tail -F log.log | grep ResponseTime | cut -d = -f 2

I have a live log file called log.log and you want to catch some suitable patterns and values ​​in it:

Example: log.log grows, and we look for lines with the pattern ResponseTime = VALUE, and we want to retrieve a consistent VALUE:

I carry out:

tail -F log.log | grep ResponseTime | cut -d = -f 2 | tr -d " "

And I expect to see

VALUE1
VALUE2
.. etc

But it does not work ... what should I do?

Thanks Namo

============

Thanks, it works now. I use: inotail -f log.log | stdbuf -oL grep ResponseTime | stdbuf -oL cut -d '=' -f 2 | stdbuf -oL tr -d ""

+3
source share
4 answers

grep stdbuf -oL grep.

. BASHFAQ/009.

+1

The reason it does not work is because some commands do not reset STDOUT with each output. Therefore, later commands never transmit anything.

I would use only one command after tail, for example:

tail -F t.log  | sed '/ResponseTime/!d;s/ResponseTime\s+=\s+(\d+)/\\1/'
+1
source

If you want to remove newlines from your output, you can do any of the following:

| cut -d = -f 2|sed -e :a -e '$!N;s/\n//;ta' 

| cut -d = -f 2|tr -d '\n'

| cut -d = -f 2|awk '{printf "%s",$0}'
-2
source

All Articles