- 论坛徽章:
- 1
|
- [root@localhost ~]# awk 'NR==FNR{a[$1]=$0;next;}{if($1 in a)print a[$1],"\t",$2,$3; a[$1]="deleted"}END{for(i in a)if(a[i]!="deleted")print a[i],"\tnull"}' file1 file2
- 10.0.86.13 proxy 10.0.86.1 gateway 10.0.86.254
- 10.0.86.12 proxy 10.0.86.1 gateway 10.0.86.1
- 10.0.86.11 proxy 10.0.86.1 gateway 10.0.86.1
- 10.0.86.10 proxy 10.0.86.1 null
- [root@localhost ~]# head file1 file2
- ==> file1 <==
- 10.0.86.10 proxy 10.0.86.1
- 10.0.86.11 proxy 10.0.86.1
- 10.0.86.12 proxy 10.0.86.1
- 10.0.86.13 proxy 10.0.86.1
- ==> file2 <==
- 10.0.86.13 gateway 10.0.86.254
- 10.0.86.12 gateway 10.0.86.1
- 10.0.86.11 gateway 10.0.86.1
复制代码 如果不符合要求,请忽略 |
|