I have a log file that has a few number of entry "classes", like this:
R0 dx=0.00500 rb=0.00000 sn=1 3145.88 2.59 0.08 se=21315 id=16190 R0 dx=0.00300 rb=-1.00000 sn=1 3150.40 2.38 0.05 se=21316 id=16191 R1 dx=-0.00500 rb=1.00000 sn=-1 3155.14 2.54 0.05 se=21317 id=16192 R1 dx=-0.02000 rb=-1.00000 sn=-1 3157.73 2.48 0.10 se=21318 id=16193 R0 dx=-0.02000 rb=0.00000 sn=-1 3160.59 2.74 0.08 se=21319 id=16194 R1 dx=0.00500 rb=1.00000 sn=1 3165.18 2.43 0.10 se=21320 id=16195 R0 dx=0.00100 rb=-1.00000 sn=1 3167.84 2.53 0.05 se=21321 id=16196 R3 dx=0.00100 rb=1.00000 sn=1 3170.11 0.10 0.10 se=21322 id=16197
I am monitoring this logfile with a
tail -F (Is there a way to make tail -F beep?)
My question is: Is there a way to calculate the sliding (moving) ratio of "number of R1 lines to number of R0 lines" to give you an example? In addition to printing this ratio I need to be able to pass it to some other tool like gnuplot to plot it (although this is might be a bit of a stretch).
Obviously this is a rather trivial thing to do in Python or MATLAB or Octave but I am very eager to learn to do it in the shell, I think the tricky part is to pass the values to a plotting utility to update a plot.