tail -f log/production.log | grep --line-buffered POST | awk '{printf "\r%d", ++i} END {print ""}'
This prints the line count after every line of input. The carriage return \r
makes each line number overwrite the last, so you only see the most recent one.
Use grep --line-buffered
to make grep flush its output after each line rather than every 4KB. Or you can combine the grep
and awk
into one:
tail -f log/production.log | awk '/POST/ {printf "\r%d", ++i} END {print ""}'