我有一个日志文件,下面是该文件中的示例日志。我只在第3和第4列更改了SourceNo,Destination以供参考。
3,16/04/17 11:32:16,Destination,Source,0,5192,16345,596444542977,16403,CrystalTech01,sup-mitto-003__0,2,3,,0,0,,0,0,107,0,0,0,2,,,,,,,,,,0,
我的要求 - 我需要单独获取,发送到目的地的源代码总计数以44代码开头。
我尝试使用grep和awk,但它没有用。
感谢您的帮助。
登录文件 -
8,16/04/17 16:18:12,2609xxxxxx,Zanaco,0,5192,0,596xxxxxx,16403,CrystalTech01,,5,1,,0,0,,1,0,108,0,0,0,,3,0,0,0,0,0,2609641xxxxx,Zanaco,,,
8,16/04/17 16:18:12,2509xxxxxx,Zanaco,0,5192,0,5964509520xxxxx,16403,CrystalTech01,,5,1,,0,0,,1,0,111,0,0,0,,3,0,0,0,0,0,260979xxxxx,Zanaco,,,
5,16/04/17 16:18:12,2609xxxxxx,Zanaco,0,5192,16329,5964509xxxxx,16403,CrystalTech01,sup-messagebird-eur-003__0,5,1,,0,0,,,0,108,0,0,0,,3,0,260964xxxx,Zanaco,,,0.005,16403,1.0,16329,
5,16/04/17 16:18:03,47783xxxxx,BetBright,0,4482,6121,596450951xxxx,0,0,sup-clx-uk__0,2,3,,0,0,,0,0,0,0,0,0,3,,,,,,,,,,1,
3,16/04/17 16:18:03,44783xxxxxx,BetBright,0,4482,6121,59645095xxxxx,0,0,sup-clx-uk__0,2,3,,0,0,,0,0,0,0,0,0,3,,,,,,,,,,1,
3,16/04/17 16:18:04,447837xxxx,BetBright,0,4482,6121,59645095xxxxxx,0,0,sup-clx-uk__0,2,3,,0,0,,0,0,0,0,0,0,3,,,,,,,,,,1,
3,16/04/17 16:18:04,447584xxxxx,BetBright,0,4482,6121,5964509509xxxxx,16448,kelfast-001,sup-clx-uk__0,2,3,,0,0,,0,0,198,0,0,0,2,,,,,,,,,,0,
我需要的示例输出 -
Zanaco 6574
BetBright 456
答案 0 :(得分:0)
如果我的意图正确,您希望对目标以44开头的记录计算行数。
我使用了一些虚拟数据。
您可以使用:
$ cat data
3,16/04/17 11:32:16,441,8,0,5192,16345,596444542977,16403,CrystalTech01,sup-mitto-003__0,2,3,,0,0,,0,0,107,0,0,0,2,,,,,,,,,,0,
3,16/04/17 11:32:16,442,1,0,5192,16345,596444542977,16403,CrystalTech01,sup-mitto-003__0,2,3,,0,0,,0,0,107,0,0,0,2,,,,,,,,,,0,
3,16/04/17 11:32:16,443,1,0,5192,16345,596444542977,16403,CrystalTech01,sup-mitto-003__0,2,3,,0,0,,0,0,107,0,0,0,2,,,,,,,,,,0,
3,16/04/17 11:32:16,413,1,0,5192,16345,596444542977,16403,CrystalTech01,sup-mitto-003__0,2,3,,0,0,,0,0,107,0,0,0,2,,,,,,,,,,0,
$ awk -F , '$3 ~ /^44/ {a[$4]++;} END {for(i in a) print "Source: " i " has count " a[i]}' data
Source: 1 has count 2
Source: 8 has count 1
$