Linux下批量处理数据


每个文件的这些关键字是不是这出现在某一行?
for data in $(ls *.dat)
do
tocell=$grep  'Total Cells:' $data|awk -F":" '{print $2 }'} #可以这样提取 也可以用cut之类的 cut -d: -f2
...
...
 
done
  
另外也可以用sed来提取你要的数据
 
反正完成一个任务有很多种选择的。
如果觉得麻烦还可以学一下perl。

不知道是不是你要的
 
#!/usr/bin/bash
 
total_cell=`sed -n -e 's/Total Cells://p' *.dat`
trans_cell=`sed -n -e 's/Transported Cells://p' *.dat`
throughput=`sed -n -e 's/Throughput://p' *.dat`
total_accept=`sed -n -e 's/Total Accepted Cells://p' *.dat`
 
echo ${total_cell} ${trans_cell} ${throughput} ${total_accept}

相关内容