#! /bin/sh# 在其他目录运行时一定要加上这样的语句# 尤其是配置在crontab里自动运行cd `dirname $0` #定义数据别名alias statdb="/usr/local/mysql -h ... -uppstat -p... statdb"# 递归访问目录# 如果文件名中包含指定日期# 则将文件当作SQL脚本入库function show(){ for i in $1/* # 因为博客园的代码插件有BUG,为了显示效果追加*/ do if [ -d $i ]; then echo $i "is directory" show $i $2 # 递归 else j=`echo $i | awk '{print index($0,"'$2'")}'` if [ $j -gt 0 ]; then cat $i | statdb -f fi fi done #遍历指定目录下文件}# 调用show "/work/stat/read/statdb" "20131208"