Last active
August 29, 2015 14:07
-
-
Save andyhuzhill/54cf878a46d04ba53f77 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
# *-* encoding: utf-8 *-* | |
# | |
# ============================================= | |
# | |
# Author : Andy Scout | |
# E-mail : [email protected] | |
# | |
# Description : 在文件夹中递归的进入每个子目录, | |
# 校验每个子目录下生成校验文件 | |
# Revision : | |
# | |
# ============================================= | |
# 全局变量记录递归层数 | |
nest=0 | |
# 记录脚本参数 | |
option=$1 | |
if [ ! "$option" ] | |
then | |
echo "Usage : ./makeshasum [make][clean][verify]" | |
exit 1 | |
fi | |
function dosha512sum() { | |
local files=$(ls -1) | |
case $option in | |
"make") | |
sha512sum * > file.sha512 ;; | |
"clean") | |
rm file.sha512 ;; | |
"verify") | |
sha512sum -c file.sha512 ;; | |
esac | |
for file in $files | |
do | |
if [ -d $file ] | |
then | |
cd $file | |
nest=$[nest+1] | |
dosha512sum | |
fi | |
done | |
if [ $nest -ne 0 ] | |
then | |
cd .. | |
nest=$[nest-1] | |
return | |
fi | |
} | |
dosha512sum | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment