#!/bin/bash # 参数校验,必须输入目录 if [ $# -eq 0 ];then echo "usage: $0 <folder> " exit 0 fi # 刨除目录末尾的/ folder=${1%/} # 判断目录是否为空 if [ ! -d $folder ];then echo "$(date) [INFO] $folder isn't a directory" exit 127 fi # 遍历目录下所有的文件 for file in `find ${folder} -type f`; do md5sum $file | sed 's#'${folder}'/##g' done