declare -r dir="$1"
declare -r md5txt="${dir}"/md5txt
for file_name in ${dir}/*
do
md5=`md5sum $file_name | cut -d ' ' -f1`
txt="\"${file_name}\":${md5}"
echo ${txt} >> md5txt
done
declare -r sha512txt="${dir}"/sha512txt
for file_name in ${dir}/*
do
sha512=`sha512sum $file_name | cut -d ' ' -f1`
txt="\"${file_name}\":${sha512}"
echo ${txt} >> sha512txt
done
运行:
bash ./md5.sh ./
结果:
“.//age_predict.cpp”:4ec0ee3a6a9c107d63d366a73885678a
“.//age_predict.h”:a27285e02599779cfb274cfecfc499d8
“.
//AMFace.cpp
”:f6110abfe0e8d48378d695dfb17426da
“.
//AMFace.h
”:13f7a6e0b22976fa407aeb817746013f
“.
//classifier.cpp
”:a6be51d912b6ccae644e641c33265892
“.
//classifier.h
”:df85ebef21277bacba6f431238ed4f94
“.
//cp2tform.cpp
”:c5b1ebef86241664821bc553083ce329
“.
//featureMethod.cpp
”:41b92d7d53075dee43c9b63b28e28ffa
“.
//featureMethod.h
”:6725bbbfff533a4fb3c825240c273b0c
“.
//md5.sh
”:d50065afadec5da1cab7d96bc303c4aa
“.
//mtcnn.cpp
”:5a2b99f8d8f372f462bfccc50f0c7033
“.
//mtcnn.h
”:fcea5c73cd381e7f86a242799dd148ed
可以自行对齐一下格式