- 从mongoexport出的转化日志中过滤出活动id和对其s1进行统计,每行显示其id及其s1出现的次数。使用逗号分隔方便excel查看
awk '{match($0,/("id":"[^]?)_/,id);match($0,/("s1":"[^"]?")/,a);x[a[1]]++}END{for(i in x){print id[1],",",i,",",x[i]}}'
- 上述结果没有加逗号分隔
awk '{match($0,/("id":"[^]?)_/,id);match($0,/("s1":"[^"]?")/,a);x[a[1]]++}END{for(i in x){print id[1],i,x[i]}}'
- 统计s1出现的次数
awk '{match($0,/("s1":"[^"]*?")/,a);x[a]++}END{for(i in x){print i,x[i]}}'
- 对当前目录下所有文件按照#1处理,将结果保存到一个文件,该文件显示所有活动的id和其s1出现的次数:
for file in $(ls)
do
awk '{match($0,/("id":"[^]?)_/,id);match($0,/("s1":"[^"]?")/,a);x[a[1]]++}END{for(i in x){print id[1],",",i,",",x[i]}}' ${file} >> ../12offers_s1_total
done
- 统计所有活动各自总共有多少转化,第一个是每个活动一个文件,第二个是一个文件包含所有活动的统计数:
for file in $(ls)
do
lines ${file} > ../12offers_sum_campConvers/${file}_sum
done
for file in $(ls)
do
linenum=$(lines ${file})
echo ${file/_total/} : ${linenum} >> ../12offers_sum_campConvers/oneFile_sum
done
- 合并新老mongodb导出的_all文件到total文件:
for id in 4922 4949 4964 4968 4969 4992 5003 5036 5055 5076 5374 5380 5471 5497 5516 4904 4921 4956 4963 4967 4972 4991 5002 5031 5048 5073 5371 5377 5467 5494 5513 4900 4918 4955 4962 4966 4971 4990 5001 5029 5046 5072 5370 5376 5466 5493 5512 4917 4948 4954 4965 4970 4989 5000 5028 5044 5071 5369 5375 5464 5492 5511 4916 4939 5027 5043 5069 5133 5170 5191 5287 5482 4915 4938 5025 5042 5067 5135 5169 5190 5286 5481 4914 4937 4946 5024 5041 5065 5134 5167 5189 5196 5269 5480 4905 4913 4936 4953 5023 5040 5064 5130 5166 5185 5284 5479 5551 4912 4933 4935 4951 5022 5039 5063 5131 5165 5187 5283 5478 5547 4911 4932 4934 4947 4950 5020 5038 5062 5132 5163 5188 5195 5261 5477 5546 5035 5054 5075 5373 5379 5470 5496 5515 5033 5052 5074 5372 5378 5468 5495 5514
do
cat 12offers/${id}all 12offer_latest/${id}all > 12offers_total/${id}_total
done
for file in $(ls)
do
linenum=$(lines ${file})
echo "total " ${file/total/} : ${linenum} >> ../12offer_sums/allCampidSumConversions_s1_total_ok
awk '{match($0,/("id":"[^]*?)/,id);match($0,/("s1":"[^"]*?")/,a);x[a[1]]++}END{for(i in x){print id[1],",",i,",",x[i]}}' ${file} >> ../12offer_sums/allCampidSumConversions_s1_total_ok
done