Grep progress bar using pv (pipe viewer)

greppv

I've got a huge directory on my computer and I need to search in every ruby file inside for a string.

I could have done it like this : grep -R "string" *.rb but it takes really long and I'd like to use pv (pipe viewer) to show a progress bar to be able to monitor grep progress.

But I don't really know how can I write this command because there are still some things I just can't understand about this command.

Has someone got any idea ?

Best Answer

pv operates on pipes (not commands) -- It is a volume gauge showing how much data has gone past a given point in the pipeline.
Your grep command is not a pipeline (| - the pipe operator is nowhere to be found) - it's just a single command doing its thing. pv can't help you here, you just have to trust that grep is actually doing its thing on all of the input files.

You could cobble something together with find, pv, xargs & grep (find . -name "*.rb" | pv | xargs grep [regex] looks like it might be promising, but you would have to tell pv how big the find output is for it to give meaningful results.

Frankly it seems like more work than it's worth. Just run your grep, wait patiently, and deal with the output when it's done.