Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MD5 progress output - BASH

Tags:

bash

md5sum

I got a simple MD5SUM script in the works. Its pretty much done except for the part that displays the progress (percent of the file that's been calculated to the user). I'm thinking of using a while loop w/ a dummy variable that checks if the MD5 has been calculated. The only problem is that md5sum (on linux) doesn't return any kind feedback, except when the actual md5sum has been calculated. So, its difficult to show the users how much of the file has been processed. Here's a copy of the script.

#!/bin/bash

#MD5 verification tool
#1st argument is file name of .iso, and the 2nd argument is the the MD5 hexsum.

echo Checking file $1 .....  
#calc md5 for file
SUM=`md5sum $1`
#insert while loop here?
#compare values
test $SUM = $2 && echo original || echo False 

#8cd98b693ce542b671edecaed48ab06d8c
# GNOME-64.iso

exit 0
like image 381
LogicalConfusion Avatar asked Oct 21 '25 12:10

LogicalConfusion


1 Answers

Use pv, installable on all major distros. SUM=$(pv "$1" | md5sum) will show a pretty progress bar with throughput and everything, something like:

bash> pv /media/secondary/backups/2013_01_12/* | md5sum
10.2GB 0:01:32 [ 115MB/s] [====>                 ] 19% ETA 0:06:21
like image 106
that other guy Avatar answered Oct 24 '25 03:10

that other guy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!