Issue

I was trying to count the number of occurrences of a word in a file on Ubuntu. This typically isn't a big deal:

grep TERM myfile.txt | wc -l

However this file is nearly 200gb and I'd like some indication of how far along I am.

pv to the rescue

I came across this post on StackOverflow: Tracking a program's progress reading through a file?

pv (Pipe Viewer) is "a terminal-based tool for monitoring the progress of data through a pipeline." Looks like exactly what I needed:

SIZE=$(ls -l myfile.txt | awk '{print $5}'); grep TERM myfile.txt | pv -s $SIZE | wc -l

SIZE in this case will be an upper bound, since pv will not receive that much data due to the grep command filtering the file.