每個文件的這些關鍵字是不是這出現在某一行?
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}