scan_file() { local f for f in $Dirs do $Find $f -type f >> $TMP_file done }
# 读取文件建立每个文件的checksum值 cr_checksum_list() { local f if [ -f $TMP_file ]; then for f in $(cat $TMP_file); do $Checker $f >> $FP done fi } rmTMP() { [ -f $TMP_file ] && rm -rf $TMP_file }
# 主程序区
# 扫描列表 scan_file
# 建立文件的checksum值 cr_checksum_list
# 清理临时文件 rmTMP
执行脚本:
复制代码 代码如下:
./my_filecheck.sh
进行校验:
复制代码 代码如下:
md5sum -c fp.20141205160628.chksum
如下:
复制代码 代码如下:
md5sum -c fp.20141209202544.chksum /bin/gawk: OK /bin/igawk: OK /bin/ln: OK /bin/loadkeys: OK /bin/gzip: OK /bin/mkdir: OK /bin/date: OK /bin/cat: OK /bin/mountpoint: OK /bin/taskset: OK /bin/umount: OK /bin/mount: OK /bin/doexec: OK /bin/kill: OK /bin/sync: OK /bin/unicode_start: OK /bin/usleep: OK /bin/mknod: OK /bin/setserial: OK /bin/cp: OK /bin/mktemp: OK /bin/setfont: OK /bin/unicode_stop: OK ..... /lib/modules/2.6.18-194.el5PAE/kernel/crypto/cast5.ko: OK /lib/modules/2.6.18-194.el5PAE/kernel/crypto/crypto_blkcipher.ko: OK /lib/modules/2.6.18-194.el5PAE/kernel/crypto/twofish.ko: OK /lib/modules/2.6.18-194.el5PAE/kernel/crypto/authenc.ko: OK /lib/modules/2.6.18-194.el5PAE/kernel/crypto/cbc.ko: OK /lib/modules/2.6.18-194.el5PAE/kernel/crypto/crypto_hash.ko: OK /lib/modules/2.6.18-194.el5PAE/kernel/crypto/seqiv.ko: OK /lib/libproc-3.2.7.so: OK /lib/libacl.so.1.1.0: OK /lib/libauparse.so.0.0.0: OK /lib/libdmraid.so.1.0.0.rc13-17: OK /lib/libvolume_id.so.0.66.0: OK /lib/libgobject-2.0.so.0.1200.3: OK /lib/libnss_compat-2.5.so: OK /lib/rtkaio/i686/nosegneg/librtkaio-2.5.so: OK /lib/rtkaio/librtkaio-2.5.so: OK /lib/libdmraid-events-isw.so.1.0.0.rc13: OK /lib/libdevmapper-event-lvm2snapshot.so.2.02: OK /lib/libblkid.so.1.0: OK /lib/libdb-4.3.so: OK /lib/libSegFault.so: OK /lib/libiw.so.28: OK /lib/libdmraid-events-isw.so.1.0.0.rc13-17: OK