文件1:
SEQUENTIAL
1001;[authentication username=1001 password=123456]
1002;[authentication username=1002 password=123456]
1003;[authentication username=1003 password=123456]
1004;[authentication username=1004 password=123456]
1005;[authentication username=1005 password=123456]
1006;[authentication username=1006 password=123456]
1007;[authentication username=1007 password=123456]
1008;[authentication username=1008 password=123456]
1009;[authentication username=1009 password=123456]
文件2:
1001;tag=dcb13e6a;Call-ID: MGRlNTQ4YzBkZmM1YjdiZTdjMGU4MzRlMmE3ODUwZGU@192.168.1.16
合并后文件3:
SEQUENTIAL;
1001;[authentication username=1001 password=123456];1001;tag=dcb13e6a;Call-ID: MGRlNTQ4YzBkZmM1YjdiZTdjMGU4MzRlMmE3ODUwZGU@192.168.1.16
1002;[authentication username=1002 password=123456];
1003;[authentication username=1003 password=123456];
1004;[authentication username=1004 password=123456];
1005;[authentication username=1005 password=123456];
1006;[authentication username=1006 password=123456];
1007;[authentication username=1007 password=123456];
1008;[authentication username=1008 password=123456];
1009;[authentication username=1009 password=123456];
合并命令:
-
awk 'BEGIN{FS=";"}{if(NR==FNR){id[$1]=$0}else{print $0";"id[$1] > "file3"}}' file2 file1
NR:当前记录数
FNR:同NR,但相对于当前文件。
阅读(1302) | 评论(0) | 转发(0) |