-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhandlemd5.sh
More file actions
executable file
·42 lines (37 loc) · 855 Bytes
/
handlemd5.sh
File metadata and controls
executable file
·42 lines (37 loc) · 855 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/bash
# calculate md5sum from a list of file and store the result
function dayumd5sum {
local fname="$mntpnt/$1"
if [[ ! -f "$fname" ]];then
echo "$fname not exist." >>$logfile
return 2
fi
local sum=$(md5sum "$fname")
if [[ $? -eq 0 ]];then
sum=$(echo "$sum" | awk '{print $1}')
echo "$sum $1" >> $reslist
return 0
else
return 1
fi
}
function usage {
echo "Usage:bash `basename $0` -f /dayupath/file -o ./filelist.md5"
echo " -f file path to do md5sum"
echo " -o result file of md5sum"
exit 2
}
mntpnt=/mnt/dayu
logfile=./md5sumlog
while getopts 'f:o:h' OPT; do
case $OPT in
f)
filename=$OPTARG;;
o)
reslist=$OPTARG;;
h)
usage;;
esac
done
dayumd5sum ${filename}
exit $?