Answer the question
In order to leave comments, you need to log in
How to get write value to variable from changing output of Linux command?
I need to get one value from the output.
tail -f access.log | pv -l -a -i10 >/dev/null
[4.2/s]
Answer the question
In order to leave comments, you need to log in
Suspiciously crooked and uncomfortable task. I suspect that you need to do something differently, I suggest writing an original problem here and discussing how to solve it.
If you really want perversions, you can send the output of the first command with `tee` to a fifo file, and from there read the desired line in parallel with something like `sed -n '5p' | cut -d\ -f2`
My colleague got interested in the question and came up with the following solution:
tailf access.log | while read -r line ; do
((a++)) ;
nd=$(date "+%s"); [ -z ${ld+x} ] && ld=$nd || if (( $nd-$ld >=10 )); then
echo "$a/10"|bc ; ld=$nd; a=0;
fi;
done
tailf access.log | awk 'BEGIN { st=systime(); } { ++count ; ct=systime(); if (ct-st >= 10) { print count/10 ; count=0; st=ct } }'
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question