#!/bin/sh
## usage: sh test_cp.sh 20 1024
##
rand(){
min=$1
max=$(($2-$min+1))
#num=$(date +%s)
num=$(cat /proc/sys/kernel/random/uuid|cksum|cut -f1 -d" ")
echo $(($num%$max+$min))
}
min_1=1
max_2=10000
lastchecksum="0"
rm -f test.bin_$1
rm -f result_$1.txt
while [ $min_1 -le $max_2 ]
do
rnd=$(rand 1 102400)
if [ "$rnd" -gt "0" ]
then
echo "rand: "$rnd >>result_$1.txt
rm -f test.bin_$1
dd if=bin_file of=test.bin_$1 skip=$rnd count=$1 bs=$2
checksum=`echo $(cat test.bin_$1|cksum)|cut -f1 -d" "`
echo "checksum:"$checksum >>result_$1.txt
if [ $lastchecksum != "0" ];then
if [ $checksum != $lastchecksum ];then
echo $checksum >> result_$1.txt
echo "checksum error" >> result_$1.txt
break
fi
fi
lastchecksum=$checksum
echo "lastchecksum="$lastchecksum
min_1=`expr $min_1 + 1`
fi
done
随机读取文件做算checksum shell 脚本
最新推荐文章于 2024-08-02 22:10:21 发布