linux 循环处理文件夹下所有文件脚本

#!/bin/bash
function ergodic(){
for file in ` ls $1 `
do
if [ -d $1"/"$file ]
then
ergodic $1"/"$file
else
cat $1"/"$file |grep HB000A001|wc -l>>/data/hxl/out.vol
#wc -L $1"/"$file | cut -d' ' -f1 >>/data/files/middle/ack/20161010
fi
done
}
INIT_PATH="/data/files/middle/vol/20161010"
ergodic $INIT_PATH

另:计数Python脚本-total.py

#!/bin/python
sum = 0
while True:
try:
str = raw_input()
except:
break
num = int(str)
sum += num
print sum

调用:

python total.py<out.vol

原文地址:https://www.cnblogs.com/xianlai-huang/p/5954078.html