Script to monitor progress of find/exec command

hi all,

i want to monitor the progress of a find and exec command, this is the code i use -

find . -type f -exec md5sum {} \; >> /md5sums/file.txt

this command works and produces a text file with all the md5sums but while running it doesnt show the progress

is there anyway i can do this

many thanks,

rob

You could try changing it to drive a loop, something like this:-

while read file
do
   printf "$file\n" >&2
   md5sum "$file"
done < <(find . -type f) >> /md5sums/file.txt

That should write to STDERR and not get captured in the output file. Can I just ask, do you mean to append to your output file? The output could be a complete overwrite because it should be the output from the find command, not each individual md5sum.

I hope that this helps,
Robin

sorry your right i dont want to append so i will be using

>

Does the suggestion do what you want?

Another might be to use xargs similar to this:-

find . -type f | xargs -tn1 md5sum > /md5sums/file.txt

The flags are:-

  • -t - write the arguments to STDERR for each run of the command named
  • -n - limit the number of arguments, in our case to 1 so we see each file click through

Do either of these work for you?

Robin

3 Likes

thanks rbatte1, i will try xargs