#!/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