- 论坛徽章:
- 0
|
回复 3# x3 - ywlscpl@ubuntu:~$ cat file
- NODE 0
- U1 N1_01 2462478
- U1 DAY01 2269231
- FIN DAY03 74180
- FIN CU 47146
- FIN UCV 40259
- NODE 1
- U1 N1_01 2462359
- FIN DAY03 74190
- FIN APAN 54761
- FIN UCV 40327
- NODE 2
- U1 N1_01 2462642
- FIN DAY03 74197
- FIN UCV 40240
- NODE 3
- U1 N1_01 2461330
- FIN DAY03 74152
- FIN UCV 40154
- NODE X
- ywlscpl@ubuntu:~$ awk '/^NODE /{a[++n]=$0;v=$0}NF>2{v1=$1" "$2;b[v1];c[v1" "v]=(v1"\t"v in c?c[v1" "v]" "$3:$3)}END{printf "%10s"," ";for (i=1;i<=n;i++) printf "\t"a[i];print "";for (i in b) {printf "%10s",i;for (j=1;j<=n;j++) printf "\t"(i" "a[j] in c?c[i" "a[j]]:" ");print ""}}' file
- NODE 0 NODE 1 NODE 2 NODE 3 NODE X
- FIN UCV 40259 40327 40240 40154
- U1 DAY01 2269231
- FIN APAN 54761
- FIN DAY03 74180 74190 74197 74152
- FIN CU 47146
- U1 N1_01 2462478 2462359 2462642 2461330
复制代码 |
|