Code
#!/bin/sh
if [ 2 -ne $# ] ; then
echo "Usage: $0 Dir File(include md5 info)"
exit
fi
if [ -f "$1" ] ; then
echo "$1 is file,Please input Dir"
echo "Usage: $0 Dir File(include md5 info)"
exit
fi
if [ -d "$2" ] ; then
echo "$2 is Dir,Please input file(include md5 info)"
echo "Usage: $0 Dir File(include md5 info)"
exit
fi
CheckDir()
{
if [ -d "$MediaCheckDir" ] ; then
echo "Please waiting"
echo "Check $MediaCheckDir"
for list in `find $MediaCheckDir`
do
if [ -f "$list" ] ; then
echo "Check file $list"
field=`echo $list | perl -0ne 'print s/\///g'`
field=`expr $field + 1`
file=`echo $list | cut -d'/' -f$field`
md5Result=`md5sum $list | cut -d' ' -f1`
checkResult=`cat $MD5Filelist | grep $file | grep $md5Result`
if [ -z "$checkResult" ] ; then
DLNAMediaMD5=`cat $MD5Filelist | grep $file`
echo "checkResult failed: $file" >> $savefile
echo "md5Result=$md5Result" >> $savefile
echo "DLNAMediaMD5=$DLNAMediaMD5" >> $savefile
echo "---------------------------------------------------------------------" >> $savefile
else
echo "checkResult success"
fi
fi
done
echo "Process over!"
else
echo "$MediaCheckDir is file!"
fi
}
BaseDir=$PWD
savefile="$BaseDir/Fail_filelist_log"
case $1 in
/*)
MediaCheckDir=$1
;;
*)
MediaCheckDir="$BaseDir/$1"
;;
esac
case $2 in
/*)
MD5Filelist=$2
;;
*)
MD5Filelist="$BaseDir/$2"
;;
esac
rm -rf $savefile
CheckDir
echo "------Checked failed Result:$savefile------"
#!/bin/sh
if [ 2 -ne $# ] ; then
echo "Usage: $0 Dir File(include md5 info)"
exit
fi
if [ -f "$1" ] ; then
echo "$1 is file,Please input Dir"
echo "Usage: $0 Dir File(include md5 info)"
exit
fi
if [ -d "$2" ] ; then
echo "$2 is Dir,Please input file(include md5 info)"
echo "Usage: $0 Dir File(include md5 info)"
exit
fi
CheckDir()
{
if [ -d "$MediaCheckDir" ] ; then
echo "Please waiting"
echo "Check $MediaCheckDir"
for list in `find $MediaCheckDir`
do
if [ -f "$list" ] ; then
echo "Check file $list"
field=`echo $list | perl -0ne 'print s/\///g'`
field=`expr $field + 1`
file=`echo $list | cut -d'/' -f$field`
md5Result=`md5sum $list | cut -d' ' -f1`
checkResult=`cat $MD5Filelist | grep $file | grep $md5Result`
if [ -z "$checkResult" ] ; then
DLNAMediaMD5=`cat $MD5Filelist | grep $file`
echo "checkResult failed: $file" >> $savefile
echo "md5Result=$md5Result" >> $savefile
echo "DLNAMediaMD5=$DLNAMediaMD5" >> $savefile
echo "---------------------------------------------------------------------" >> $savefile
else
echo "checkResult success"
fi
fi
done
echo "Process over!"
else
echo "$MediaCheckDir is file!"
fi
}
BaseDir=$PWD
savefile="$BaseDir/Fail_filelist_log"
case $1 in
/*)
MediaCheckDir=$1
;;
*)
MediaCheckDir="$BaseDir/$1"
;;
esac
case $2 in
/*)
MD5Filelist=$2
;;
*)
MD5Filelist="$BaseDir/$2"
;;
esac
rm -rf $savefile
CheckDir
echo "------Checked failed Result:$savefile------"
来源:https://www.cnblogs.com/blueoceanli/archive/2009/01/06/1370384.html