三、性能比较
[chengmo@localhost nginx]# time (awk 'BEGIN{ total=0;for(i=0;i<=10000;i++){total+=i;}print total;}')
50005000
real 0m0.003s
user 0m0.003s
sys 0m0.000s
[chengmo@localhost nginx]# time(total=0;for i in $(seq 10000);do total=$(($total+i));done;echo $total;)
50005000
real 0m0.141s
user 0m0.125s
sys 0m0.008s
实现相同功能,可以看到awk实现的性能是shell的50倍!