💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
第一个版本: ``` #!/bin/bash log_name="nginx_access.log" url_path="/test/nginx/all_log/script/url_list.txt" for i in $(seq -w 21 28) do for u in $(cat ${url_path}) do cd /test/nginx/all_log/201805${i} && \ echo "time:201805${i}" echo "url:${u}" echo "PV:" $(grep "${u}" ${log_name}|wc -l) grep "${u}" ${log_name}|awk -F"[ \"]+" '{sum+=$(NF-1)} END {print "all-time:",sum/NR}' && \ grep "${u}" ${log_name}|awk -F"[ \"]+" '{sum+=$NF} END {print "PHP-NGINX:,"sum/NR}' echo "\n" done done ``` 第二个版本: 保存成CSV格式,使用excel可以打开查看 ``` #!/bin/bash log_name="bbs.goumin.com_access.log" url_path="/root/url_time/url_list.txt" echo "url,date,nginx_time,php_time" > /root/url_time/time1.csv for u in $(cat ${url_path}) do for i in $(seq -w 29 30) do cd /root/url_time/201805${i} nginx_time=$(grep "${u}" ${log_name}|awk -F"[ \"]+" '{sum+=$(NF-1)} END {printf("%.2f\n",sum/NR)}') php_time=$(grep "${u}" ${log_name}|awk -F"[ \"]+" '{sum+=$NF} END {printf("%.2f\n",sum/NR)}') echo "${u},${i},${nginx_time},${php_time}" >> /root/url_time/time1.csv done done ``` 效果: ![](https://box.kancloud.cn/3b0d2f6c2b646ae12d37206e94757140_487x284.png) 后期完善版使用pyton来操作excel表格: 1.调整列宽 2.将第一行标题加黑加粗 3.将相同接口的表格合并居中 4.不同接口区块标注不同的颜色