zgrep '123:abc,456' /data/log | awk -F'123:' '{split($2,id,",");x[id[1]]++;} END {for(a in x) print a}'
比如只想拉取到abc,但是zgrep拉取到类似'123:abc,456'一大段字符,就可以使用awk做处理。
-F'123:'
是把这段字符从123:处分隔成2段,123:是$1,后面是$2。
split($2,id,",")
是把$2这段字符串从开始到下一个“,"处截取并保存到id里。后面的代码就是循环并输出。