- 论坛徽章:
- 9
|
- li@vm-test:~/test$ cat test.awk
- BEGIN{
- FS="[ -.]"
- }
- {
- a[$4][$NF][NR]=$0;
- }
- END{
- p=asorti(a,b)
- for(i=1;i<=p;i++){
- q=asorti(a[b[i]],c,"@ind_num_asc");
- for(j=1;j<=q;j++){
- for(k in a[b[i]][c[j]])
- print a[b[i]][c[j]][k];
- }
- }
- }
- li@vm-test:~/test$ awk -f test.awk test.txt
- ab-cd-cc-aa 1.2.3.42
- ab-cd-cc-aa 1.2.3.42
- ab-cd-rc-ab 3.2.3.46
- aa-er-vd-cd 3.4.5.61
- bc-ki-ee-db 0.3.4.12
- bc-ki-ee-db 0.3.4.125
- bc-ki-ee-ee 0.3.4.5
- ab-cd-cc-ee 1.2.3.41
- zz-sd-jk-ee 5.6.7.82
- ad-ee-cd-er 5.4.3.23
- ee-ad-df-fc 4.5.6.7
- ee-ad-df-fc 4.5.6.9
- ee-ad-df-fc 4.5.6.21
- fd-fe-er-fe 2.3.4.51
- bc-ki-de-fg 0.3.4.25
- bc-ki-de-fg 0.3.4.225
复制代码 |
|