Linux find command - show progress
I was wondering if there's any way to display some kind of progress info when searching for files in linux using find
. I often find myself searching for files on a big disk and some kind of progress indicator would be very helpfull, like a bar or at least the current directory "find" searches in. Are there any scripts that do that, or does find
support some hooks?
with this trick you can see the current folder - but no progress bar - sorry.
watch readlink -f /proc/$(pidof find)/cwd
A little utility called pv (pipe viewer) may help. From the fantastic summary by Peteris Krumins:
Pipe viewer is a terminal-based tool for monitoring the progress of data through a pipeline.
You can use pv in a number of ways. When playing around here, I put it immediately after a pipe to monitor progress of the output generated by find (should pass stdin to stdout untouched)
find / -mtime -1h | pv > /dev/null
which will show output a bit like this:
6.42MB 0:01:25 [31.7kB/s] [ <=> ]
(I redirected stdout to /dev/null so I could see the progress bar in action without output flying by. This is likely not your intent with find, so tailor accordingly)
I'm honestly not sure how well this works in the wild. For "expensive" finds like the one above (traversing from root), it appeared to work fairly well. For simpler commands in a deeper node in the directory tree, pv failed miserably. These commands are returning results immediately, so a progress bar is probably moot here.
At any rate, play around and see if this works at all for what you need. Food for thought, at least.