How to do a continous 'wc -l' with gnu texttools?

Maybe:

tail -n +1 -f file | awk '{printf "\r%lu", NR}'

Beware that it would output a number for every line of input (though overriding the previous value if sent to a terminal).

Or you can implement the tail -f by hand in shell:

n=0
while :; do 
  n=$(($n + $(wc -l)))
  printf '\r%s' "$n"
  sleep 1
done < file

(note that it runs up to one wc and one sleep command per second which not all shells have built in. With ksh93 while sleep is builtin, to get a built in wc (at least on Debian), you need to add /opt/ast/bin at the front of $PATH (regardless of whether that directory exists or not) or use command /opt/ast/bin/wc (don't ask...)).

You could use pv, as in:

tail -n +1 -f file | pv -bl > /dev/null

But beware that it adds k, M... suffixes when the number is over 1000 (and there doesn't seem to be a way around that).


Try to count it with pure bash without wc:

a=0 ; tail -f file | while read -r line ; do ((a++)) ; echo $a ; done

or even like this to rewrite previous value:

a=0 ; tail -f file | while read -r line ; do ((a++)) ; echo -ne "\r$a" ; done