It's not clear from the OP how many files are selected by the find command, and if the do-something has any significant impact on the overall processing time.
Assuming one of the common cases, where (1) find
will scan large number of folders (2) relatively small number of matches and (3) little processing for each file, it is possible to create progress indication by logging directory that are scanned.
If the original find was using find STARTING-POINT ... FIND-EXPRESSION
, the modified command is find STARTING-POINT '(' LOGGING-EXPRESSION ')' -o '( FIND-EXPRESSION ')'
.
Following script will produce a progress report whenever find start scanning a new folder. Note that FIND-EXPRESSION should include explicit '-print', if the original find was relying on the implicit -print.
find STARTING-POINT \
'(' -type d -maxdepth 3 -fprintf /dev/stderr "Processing: %p" ')' \
-o \
'(' FIND-EXPRESSION ')'
# Single Line
find STARTING-POINT '(' -type d -maxdepth N -fprintf /dev/stderr "Processing\n: %p" ')' -oo '(' FIND-EXPRESSION ')'
The above will log each scanned folder (up to N level deep) to stderr.
Example:
# Find all '*.py' files on the system, showing '*' for each folder
find / '(' -type d -fprintf /dev/stderr "*" ')' -o '(' -name '*.py' -print ')'
# Find system '*.so' files, showing each folder scanned
find /lib /usr/lib '(' -type d -fprintf /dev/stderr "Scanning: %p" ')' -o '(' -name '*.so' -print ')'
Additional customization to the logging can be performed - Using the '-regex' or '-path' in the logging filter