- 论坛徽章:
- 0
|
吃饭回来答题
- awk 'NR==FNR{a[$1]=$2}NR>FNR{if ($0~/[0-9][0-9]:[0-9][0-9]:[0-9][0-9] [0-9]+$/) day=$NF"|"a[$2]"|"$3;else {split($1,M,":");b[day"|"M[1]"|"$2]++}}END{for (i in b) print i"|"b[i]}' <(for i in `seq 1 12`; do LANG=C cal -1 $i 2009 |awk 'NR==1{printf "%s %02d\n",substr($1,1,3),"'$i'";exit}'; done) file |sort -k1,4
复制代码
- [root@Mylinux tmp]# awk 'NR==FNR{a[$1]=$2}NR>FNR{if ($0~/[0-9][0-9]:[0-9][0-9]:[0-9][0-9] [0-9]+$/) day=$NF"|"a[$2]"|"$3;else {split($1,M,":");b[day"|"M[1]"|"$2]++}}END{for (i in b) print i"|"b[i]}' <(for i in `seq 1 12`; do LANG=C cal -1 $i 2009 |awk 'NR==1{printf "%s %02d\n",substr($1,1,3),"'$i'";exit}'; done) file |sort -t"|" -k1,4
- 2009|06|28|09|ERROR1|2
- 2009|06|28|10|ERROR1|1
- 2009|06|28|10|ERROR2|1
- 2009|06|28|11|ERROR2|2
- 2009|06|29|15|ERROR3|2
- 2009|06|29|16|ERROR4|1
- 2009|06|29|16|FIFO|2
- 2009|06|30|||1
复制代码 |
|