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

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM