可以請教一下如何把shell script 改寫成 perl ?
#!/bin/bash
echo $b
echo $fileday
echo $datatype
# Count Daily Total History:
for i in $datatype
do
gzcat $addToPath/PM.$b.$fileday.*.xml.gz |grep $i >> $addToPath/$i.log
done
# Summation Daily Total Counts:
for i in $datatype
do
total=0
number=0
filename=$addToPath/$i.log
while read line
do
number=` echo $line | cut -d '>' -f2 | cut -d '<' -f1 `
let total+=number
done < $filename
echo " the $i total sum = $total" >> $addToPath/$result_file
cat $addToPath/$result_file
done
echo $b
echo $fileday
echo $datatype
# Count Daily Total History:
for i in $datatype
do
gzcat $addToPath/PM.$b.$fileday.*.xml.gz |grep $i >> $addToPath/$i.log
done
# Summation Daily Total Counts:
for i in $datatype
do
total=0
number=0
filename=$addToPath/$i.log
while read line
do
number=` echo $line | cut -d '>' -f2 | cut -d '<' -f1 `
let total+=number
done < $filename
echo " the $i total sum = $total" >> $addToPath/$result_file
cat $addToPath/$result_file
done
作者: citiwang 发布时间: 2011-06-02
学一点Perl就可以。
作者: 2gua 发布时间: 2011-06-02